<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Sizzle Performance Suite HTML</title>
	<link rel="shortcut icon" href="../images/favicon.ico">
</head>
	<script type="text/javascript">
		var templateString = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<html>\n<head>\n<title>XML Path Language (XPath)</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.w3.org/StyleSheets/TR/W3C-REC\"/>\n<style type=\"text/css\">code { font-family: monospace }</style>\n</head>\n<body>\n<div class=\"head\">\n<a href=\"http://www.w3.org/\"><img src=\"http://www.w3.org/Icons/WWW/w3c_home\" alt=\"W3C\" height=\"48\" width=\"72\"/></a>\n<h1>XML Path Language (XPath)<br/>Version 1.0</h1>\n<h2>W3C Recommendation 16 November 1999</h2>\n<dl>\n<dt>This version:</dt>\n<dd>\n<a href=\"http://www.w3.org/TR/1999/REC-xpath-19991116\">http://www.w3.org/TR/1999/REC-xpath-19991116</a>\n<br/>\n(available in <a href=\"http://www.w3.org/TR/1999/REC-xpath-19991116.xml\">XML</a> or \n<a href=\"http://www.w3.org/TR/1999/REC-xpath-19991116.html\">HTML</a>)\n\n</dd>\n<dt>Latest version:</dt>\n<dd>\n<a href=\"http://www.w3.org/TR/xpath\">http://www.w3.org/TR/xpath</a>\n<br/>\n</dd>\n<dt>Previous versions:</dt>\n<dd>\n<a href=\"http://www.w3.org/TR/1999/PR-xpath-19991008\">http://www.w3.org/TR/1999/PR-xpath-19991008</a>\n<br/>\n<a href=\"http://www.w3.org/1999/08/WD-xpath-19990813\">http://www.w3.org/1999/08/WD-xpath-19990813</a>\n<br/>\n<a href=\"http://www.w3.org/1999/07/WD-xpath-19990709\">http://www.w3.org/1999/07/WD-xpath-19990709</a>\n<br/>\n<a href=\"http://www.w3.org/TR/1999/WD-xslt-19990421\">http://www.w3.org/TR/1999/WD-xslt-19990421</a>\n<br/>\n</dd>\n<dt>Editors:</dt>\n<dd>\n\nJames Clark\n<a href=\"mailto:jjc@jclark.com\"> jjc@jclark.com </a>\n<br/>\n\nSteve DeRose\n (Inso Corp. and Brown University) \n<a href=\"mailto:Steven_DeRose@Brown.edu\"> Steven_DeRose@Brown.edu </a>\n<br/>\n</dd>\n</dl>\n<p class=\"copyright\">\n<a href=\"http://www.w3.org/Consortium/Legal/ipr-notice.html#Copyright\">\n\t\tCopyright</a>     1999 <a href=\"http://www.w3.org\">W3C</a><sup> </sup>\n\t\t(<a href=\"http://www.lcs.mit.edu\">MIT</a>,\n\t\t<a href=\"http://www.inria.fr/\">INRIA</a>,\n\t\t<a href=\"http://www.keio.ac.jp/\">Keio</a>), All Rights Reserved. W3C\n\t\t<a href=\"http://www.w3.org/Consortium/Legal/ipr-notice.html#Legal_Disclaimer\">liability</a>,\n\t\t<a href=\"http://www.w3.org/Consortium/Legal/ipr-notice.html#W3C_Trademarks\">trademark</a>,\n\t\t<a href=\"http://www.w3.org/Consortium/Legal/copyright-documents.html\">document use</a> and\n\t\t<a href=\"http://www.w3.org/Consortium/Legal/copyright-software.html\">software licensing</a> rules apply.\n</p>\n<hr title=\"Separator for header\"/>\n</div>\n<h2>\n<a name=\"abstract\">Abstract</a>\n</h2>\n<p>XPath is a language for addressing parts of an XML\ndocument, designed to be used by both XSLT and\nXPointer.</p>\n<h2>\n<a name=\"status\">Status of this document</a>\n</h2>\n\n<p>This document has been reviewed by W3C Members and other interested\nparties and has been endorsed by the Director as a W3C <a href=\"http://www.w3.org/Consortium/Process/#RecsW3C\">Recommendation</a>. It\nis a stable document and may be used as reference material or cited as\na normative reference from other documents. W3C's role in making the\nRecommendation is to draw attention to the specification and to\npromote its widespread deployment. This enhances the functionality and\ninteroperability of the Web.</p>\n\n<p>The list of known errors in this specification is available at\n<a href=\"http://www.w3.org/1999/11/REC-xpath-19991116-errata\">http://www.w3.org/1999/11/REC-xpath-19991116-errata</a>.</p>\n\n<p>Comments on this specification may be sent to <a href=\"mailto:www-xpath-comments@w3.org\">www-xpath-comments@w3.org</a>; <a href=\"http://lists.w3.org/Archives/Public/www-xpath-comments\">archives</a>\nof the comments are available.</p>\n\n<p>The English version of this specification is the only normative\nversion. However, for translations of this document, see <a href=\"http://www.w3.org/Style/XSL/translations.html\">http://www.w3.org/Style/XSL/translations.html</a>.</p>\n\n<p>A list of current W3C Recommendations and other technical documents\ncan be found at <a href=\"http://www.w3.org/TR\">http://www.w3.org/TR</a>.</p>\n\n<p>This specification is joint work of the XSL Working Group and the\nXML Linking Working Group and so is part of the <a href=\"http://www.w3.org/Style/Activity\">W3C Style activity</a> and\nof the <a href=\"http://www.w3.org/XML/Activity\">W3C XML\nactivity</a>.</p>\n\n\n<h2>\n<a name=\"contents\">Table of contents</a>\n</h2>1 <a href=\"#section-Introduction\">Introduction</a>\n<br/>2 <a href=\"#location-paths\">Location Paths</a>\n<br/>    2.1 <a href=\"#section-Location-Steps\">Location Steps</a>\n<br/>    2.2 <a href=\"#axes\">Axes</a>\n<br/>    2.3 <a href=\"#node-tests\">Node Tests</a>\n<br/>    2.4 <a href=\"#predicates\">Predicates</a>\n<br/>    2.5 <a href=\"#path-abbrev\">Abbreviated Syntax</a>\n<br/>3 <a href=\"#section-Expressions\">Expressions</a>\n<br/>    3.1 <a href=\"#section-Basics\">Basics</a>\n<br/>    3.2 <a href=\"#section-Function-Calls\">Function Calls</a>\n<br/>    3.3 <a href=\"#node-sets\">Node-sets</a>\n<br/>    3.4 <a href=\"#booleans\">Booleans</a>\n<br/>    3.5 <a href=\"#numbers\">Numbers</a>\n<br/>    3.6 <a href=\"#strings\">Strings</a>\n<br/>    3.7 <a href=\"#exprlex\">Lexical Structure</a>\n<br/>4 <a href=\"#corelib\">Core Function Library</a>\n<br/>    4.1 <a href=\"#section-Node-Set-Functions\">Node Set Functions</a>\n<br/>    4.2 <a href=\"#section-String-Functions\">String Functions</a>\n<br/>    4.3 <a href=\"#section-Boolean-Functions\">Boolean Functions</a>\n<br/>    4.4 <a href=\"#section-Number-Functions\">Number Functions</a>\n<br/>5 <a href=\"#data-model\">Data Model</a>\n<br/>    5.1 <a href=\"#root-node\">Root Node</a>\n<br/>    5.2 <a href=\"#element-nodes\">Element Nodes</a>\n<br/>        5.2.1 <a href=\"#unique-id\">Unique IDs</a>\n<br/>    5.3 <a href=\"#attribute-nodes\">Attribute Nodes</a>\n<br/>    5.4 <a href=\"#namespace-nodes\">Namespace Nodes</a>\n<br/>    5.5 <a href=\"#section-Processing-Instruction-Nodes\">Processing Instruction Nodes</a>\n<br/>    5.6 <a href=\"#section-Comment-Nodes\">Comment Nodes</a>\n<br/>    5.7 <a href=\"#section-Text-Nodes\">Text Nodes</a>\n<br/>6 <a href=\"#section-Conformance\">Conformance</a>\n<br/>\n<h3>Appendices</h3>A <a href=\"#section-References\">References</a>\n<br/>    A.1 <a href=\"#section-Normative-References\">Normative References</a>\n<br/>    A.2 <a href=\"#section-Other-References\">Other References</a>\n<br/>B <a href=\"#infoset\">XML Information Set Mapping</a> (Non-Normative)<br/>\n<hr/>\n\n\n<h2>\n<a name=\"section-Introduction\"></a>1 Introduction</h2>\n\n<p>XPath is the result of an effort to provide a common syntax and\nsemantics for functionality shared between XSL Transformations <a href=\"#XSLT\">[XSLT]</a> and XPointer <a href=\"#XPTR\">[XPointer]</a>.  The primary purpose\nof XPath is to address parts of an XML <a href=\"#XML\">[XML]</a> document.\nIn support of this primary purpose, it also provides basic facilities\nfor manipulation of strings, numbers and booleans.  XPath uses a\ncompact, non-XML syntax to facilitate use of XPath within URIs and XML\nattribute values.  XPath operates on the abstract, logical structure\nof an XML document, rather than its surface syntax.  XPath gets its\nname from its use of a path notation as in URLs for navigating through\nthe hierarchical structure of an XML document.</p>\n\n<p>In addition to its use for addressing, XPath is also designed so\nthat it has a natural subset that can be used for matching (testing\nwhether or not a node matches a pattern); this use of XPath is\ndescribed in <a href=\"http://www.w3.org/TR/WD-xslt#patterns\">XSLT</a>.</p>\n\n<p>XPath models an XML document as a tree of nodes.  There are\ndifferent types of nodes, including element nodes, attribute nodes and\ntext nodes.  XPath defines a way to compute a <a href=\"#dt-string-value\">string-value</a> for each type of node.\nSome types of nodes also have names.  XPath fully supports XML\nNamespaces <a href=\"#XMLNAMES\">[XML Names]</a>.  Thus, the name of a node is\nmodeled as a pair consisting of a local part and a possibly null\nnamespace URI; this is called an <a href=\"#dt-expanded-name\">expanded-name</a>.  The data model is\ndescribed in detail in <a href=\"#data-model\">[<b>5 Data Model</b>]</a>.</p>\n\n<p>The primary syntactic construct in XPath is the expression.  An\nexpression matches the production <a href=\"#NT-Expr\">Expr</a>.  An\nexpression is evaluated to yield an object, which has one of the\nfollowing four basic types:</p>\n\n<ul>\n\n<li>node-set (an unordered collection of nodes without duplicates)</li>\n\n<li>boolean (true or false)</li>\n\n<li>number (a floating-point number)</li>\n\n<li>string (a sequence of UCS characters)</li>\n\n</ul>\n\n<p>Expression evaluation occurs with respect to a context.  XSLT and\nXPointer specify how the context is determined for XPath expressions\nused in XSLT and XPointer respectively.  The context consists of:</p>\n\n<ul>\n\n<li>a node (<a name=\"dt-context-node\"></a>the\n<b>context node</b>)</li>\n\n<li>a pair of non-zero positive integers (<a name=\"dt-context-position\"></a>the <b>context\nposition</b> and <a name=\"dt-context-size\"></a>the <b>context size</b>)</li>\n\n<li>a set of variable bindings</li>\n\n<li>a function library</li>\n\n<li>the set of namespace declarations in scope for the\nexpression</li>\n\n</ul>\n\n<p>The context position is always less than or equal to the\ncontext size.</p>\n\n<p>The variable bindings consist of a mapping from variable names to\nvariable values.  The value of a variable is an object, which can be of\nany of the types that are possible for the value of an expression,\nand may also be of additional types not specified here.</p>\n\n<p>The function library consists of a mapping from function names to\nfunctions.  Each function takes zero or more arguments and returns a\nsingle result.  This document defines a core function library that all\nXPath implementations must support (see <a href=\"#corelib\">[<b>4 Core Function Library</b>]</a>).\nFor a function in the core function library, arguments and result are\nof the four basic types.  Both XSLT and XPointer extend XPath by\ndefining additional functions; some of these functions operate on the\nfour basic types; others operate on additional data types defined by\nXSLT and XPointer.</p>\n\n<p>The namespace declarations consist of a mapping from prefixes to\nnamespace URIs.</p>\n\n<p>The variable bindings, function library and namespace declarations\nused to evaluate a subexpression are always the same as those used to\nevaluate the containing expression.  The context node, context\nposition, and context size used to evaluate a subexpression are\nsometimes different from those used to evaluate the containing\nexpression. Several kinds of expressions change the context node; only\npredicates change the context position and context size (see <a href=\"#predicates\">[<b>2.4 Predicates</b>]</a>).  When the evaluation of a kind of expression is\ndescribed, it will always be explicitly stated if the context node,\ncontext position, and context size change for the evaluation of\nsubexpressions; if nothing is said about the context node, context\nposition, and context size, they remain unchanged for the\nevaluation of subexpressions of that kind of expression.</p>\n\n<p>XPath expressions often occur in XML attributes.  The grammar\nspecified in this section applies to the attribute value after XML 1.0\nnormalization.  So, for example, if the grammar uses the character\n<code> </code>, this must not appear in the XML source as\n<code> </code> but must be quoted according to XML 1.0 rules by,\nfor example, entering it as <code> lt;</code>. Within expressions,\nliteral strings are delimited by single or double quotation marks,\nwhich are also used to delimit XML attributes. To avoid a quotation\nmark in an expression being interpreted by the XML processor as\nterminating the attribute value the quotation mark can be entered as a\ncharacter reference (<code> quot;</code> or\n<code> apos;</code>).  Alternatively, the expression can use single\nquotation marks if the XML attribute is delimited with double\nquotation marks or vice-versa.</p>\n\n<p>One important kind of expression is a location path.  A location\npath selects a set of nodes relative to the context node.  The result\nof evaluating an expression that is a location path is the node-set\ncontaining the nodes selected by the location path.  Location paths\ncan recursively contain expressions that are used to filter sets of\nnodes.  A location path matches the production <a href=\"#NT-LocationPath\">LocationPath</a>.</p>\n\n<p>In the following grammar, the non-terminals <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> and <a href=\"http://www.w3.org/TR/REC-xml-names#NT-NCName\">NCName</a> are defined in <a href=\"#XMLNAMES\">[XML Names]</a>, and <a href=\"http://www.w3.org/TR/REC-xml#NT-S\">S</a> is defined in\n<a href=\"#XML\">[XML]</a>.  The grammar uses the same EBNF notation as\n<a href=\"#XML\">[XML]</a> (except that grammar symbols always have initial\ncapital letters).</p>\n\n<p>Expressions are parsed by first dividing the character string to be\nparsed into tokens and then parsing the resulting sequence of tokens.\nWhitespace can be freely used between tokens.  The tokenization\nprocess is described in <a href=\"#exprlex\">[<b>3.7 Lexical Structure</b>]</a>.</p>\n\n\n\n\n<h2>\n<a name=\"location-paths\"></a>2 Location Paths</h2>\n\n<p>Although location paths are not the most general grammatical\nconstruct in the language (a <a href=\"#NT-LocationPath\">LocationPath</a> is a special case of an <a href=\"#NT-Expr\">Expr</a>), they are the most important construct and\nwill therefore be described first.</p>\n\n<p>Every location path can be expressed using a straightforward but\nrather verbose syntax.  There are also a number of syntactic\nabbreviations that allow common cases to be expressed concisely.  This\nsection will explain the semantics of location paths using the\nunabbreviated syntax.  The abbreviated syntax will then be explained\nby showing how it expands into the unabbreviated syntax (see <a href=\"#path-abbrev\">[<b>2.5 Abbreviated Syntax</b>]</a>).</p>\n\n<p>Here are some examples of location paths using the unabbreviated\nsyntax:</p>\n\n<ul>\n\n<li>\n<p>\n<code>child::para</code> selects the\n<code>para</code> element children of the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::*</code> selects all element\nchildren of the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::text()</code> selects all text\nnode children of the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::node()</code> selects all the\nchildren of the context node, whatever their node type</p>\n</li>\n\n<li>\n<p>\n<code>attribute::name</code> selects the\n<code>name</code> attribute of the context node</p>\n</li>\n\n<li>\n<p>\n<code>attribute::*</code> selects all the\nattributes of the context node</p>\n</li>\n\n<li>\n<p>\n<code>descendant::para</code> selects the\n<code>para</code> element descendants of the context node</p>\n</li>\n\n<li>\n<p>\n<code>ancestor::div</code> selects all <code>div</code>\nancestors of the context node</p>\n</li>\n\n<li>\n<p>\n<code>ancestor-or-self::div</code> selects the\n<code>div</code> ancestors of the context node and, if the context node is a\n<code>div</code> element, the context node as well</p>\n</li>\n\n<li>\n<p>\n<code>descendant-or-self::para</code> selects the\n<code>para</code> element descendants of the context node and, if the context node is\na <code>para</code> element, the context node as well</p>\n</li>\n\n<li>\n<p>\n<code>self::para</code> selects the context node if it is a\n<code>para</code> element, and otherwise selects nothing</p>\n</li>\n\n<li>\n<p>\n<code>child::chapter/descendant::para</code>\nselects the <code>para</code> element descendants of the\n<code>chapter</code> element children of the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::*/child::para</code> selects\nall <code>para</code> grandchildren of the context node</p>\n</li>\n\n<li>\n<p>\n<code>/</code> selects the document root (which is\nalways the parent of the document element)</p>\n</li>\n\n<li>\n<p>\n<code>/descendant::para</code> selects all the\n<code>para</code> elements in the same document as the context node</p>\n</li>\n\n<li>\n<p>\n<code>/descendant::olist/child::item</code> selects all the\n<code>item</code> elements that have an <code>olist</code> parent and\nthat are in the same document as the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::para[position()=1]</code> selects the first\n<code>para</code> child of the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::para[position()=last()]</code> selects the last\n<code>para</code> child of the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::para[position()=last()-1]</code> selects\nthe last but one <code>para</code> child of the context node</p>\n</li>\n\n<li>\n<p>\n<code>child::para[position() 1]</code> selects all\nthe <code>para</code> children of the context node other than the\nfirst <code>para</code> child of the context node</p>\n</li>\n\n<li>\n<p>\n<code>following-sibling::chapter[position()=1]</code>\nselects the next <code>chapter</code> sibling of the context node</p>\n</li>\n\n<li>\n<p>\n<code>preceding-sibling::chapter[position()=1]</code>\nselects the previous <code>chapter</code> sibling of the context\nnode</p>\n</li>\n\n<li>\n<p>\n<code>/descendant::figure[position()=42]</code> selects\nthe forty-second <code>figure</code> element in the\ndocument</p>\n</li>\n\n<li>\n<p>\n<code>/child::doc/child::chapter[position()=5]/child::section[position()=2]</code>\nselects the second <code>section</code> of the fifth\n<code>chapter</code> of the <code>doc</code> document\nelement</p>\n</li>\n\n<li>\n<p>\n<code>child::para[attribute::type=\"warning\"]</code>\nselects all <code>para</code> children of the context node that have a\n<code>type</code> attribute with value <code>warning</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>child::para[attribute::type='warning'][position()=5]</code>\nselects the fifth <code>para</code> child of the context node that has\na <code>type</code> attribute with value\n<code>warning</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>child::para[position()=5][attribute::type=\"warning\"]</code>\nselects the fifth <code>para</code> child of the context node if that\nchild has a <code>type</code> attribute with value\n<code>warning</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>child::chapter[child::title='Introduction']</code>\nselects the <code>chapter</code> children of the context node that\nhave one or more <code>title</code> children with <a href=\"#dt-string-value\">string-value</a> equal to\n<code>Introduction</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>child::chapter[child::title]</code> selects the\n<code>chapter</code> children of the context node that have one or\nmore <code>title</code> children</p>\n</li>\n\n<li>\n<p>\n<code>child::*[self::chapter or self::appendix]</code>\nselects the <code>chapter</code> and <code>appendix</code> children of\nthe context node</p>\n</li>\n\n<li>\n<p>\n<code>child::*[self::chapter or\nself::appendix][position()=last()]</code> selects the last\n<code>chapter</code> or <code>appendix</code> child of the context\nnode</p>\n</li>\n\n</ul>\n\n<p>There are two kinds of location path: relative location paths\nand absolute location paths.</p>\n\n<p>A relative location path consists of a sequence of one or more\nlocation steps separated by <code>/</code>.  The steps in a relative\nlocation path are composed together from left to right.  Each step in\nturn selects a set of nodes relative to a context node. An initial\nsequence of steps is composed together with a following step as\nfollows.  The initial sequence of steps selects a set of nodes\nrelative to a context node.  Each node in that set is used as a\ncontext node for the following step.  The sets of nodes identified by\nthat step are unioned together.  The set of nodes identified by\nthe composition of the steps is this union. For example,\n<code>child::div/child::para</code> selects the\n<code>para</code> element children of the <code>div</code> element\nchildren of the context node, or, in other words, the\n<code>para</code> element grandchildren that have <code>div</code>\nparents.</p>\n\n<p>An absolute location path consists of <code>/</code> optionally\nfollowed by a relative location path.  A <code>/</code> by itself\nselects the root node of the document containing the context node.  If\nit is followed by a relative location path, then the location path\nselects the set of nodes that would be selected by the relative\nlocation path relative to the root node of the document containing the\ncontext node.</p>\n\n<h5>Location Paths</h5>\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-LocationPath\"></a>[1]   </td><td>LocationPath</td><td>   ::=   </td><td><a href=\"#NT-RelativeLocationPath\">RelativeLocationPath</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AbsoluteLocationPath\">AbsoluteLocationPath</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AbsoluteLocationPath\"></a>[2]   </td><td>AbsoluteLocationPath</td><td>   ::=   </td><td>'/' <a href=\"#NT-RelativeLocationPath\">RelativeLocationPath</a>?</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AbbreviatedAbsoluteLocationPath\">AbbreviatedAbsoluteLocationPath</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-RelativeLocationPath\"></a>[3]   </td><td>RelativeLocationPath</td><td>   ::=   </td><td><a href=\"#NT-Step\">Step</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-RelativeLocationPath\">RelativeLocationPath</a> '/' <a href=\"#NT-Step\">Step</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AbbreviatedRelativeLocationPath\">AbbreviatedRelativeLocationPath</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n<h3>\n<a name=\"section-Location-Steps\"></a>2.1 Location Steps</h3>\n\n<p>A location step has three parts:</p>\n\n<ul>\n\n<li>\n<p>an axis, which specifies the tree relationship between the\nnodes selected by the location step and the context node,</p>\n</li>\n\n<li>\n<p>a node test, which specifies the node type and <a href=\"#dt-expanded-name\">expanded-name</a> of the nodes selected\nby the location step, and</p>\n</li>\n\n<li>\n<p>zero or more predicates, which use arbitrary expressions to\nfurther refine the set of nodes selected by the location\nstep.</p>\n</li>\n\n</ul>\n\n<p>The syntax for a location step is the axis name and node test\nseparated by a double colon, followed by zero or more expressions each\nin square brackets. For example, in\n<code>child::para[position()=1]</code>, <code>child</code> is the name\nof the axis, <code>para</code> is the node test and\n<code>[position()=1]</code> is a predicate.</p>\n\n<p>The node-set selected by the location step is the node-set that\nresults from generating an initial node-set from the axis and\nnode-test, and then filtering that node-set by each of the predicates\nin turn.</p>\n\n<p>The initial node-set consists of the nodes having the relationship\nto the context node specified by the axis, and having the node type\nand <a href=\"#dt-expanded-name\">expanded-name</a> specified\nby the node test.  For example, a location step\n<code>descendant::para</code> selects the <code>para</code> element\ndescendants of the context node: <code>descendant</code> specifies\nthat each node in the initial node-set must be a descendant of the\ncontext; <code>para</code> specifies that each node in the initial\nnode-set must be an element named <code>para</code>.  The available\naxes are described in <a href=\"#axes\">[<b>2.2 Axes</b>]</a>.  The available node tests\nare described in <a href=\"#node-tests\">[<b>2.3 Node Tests</b>]</a>.  The meaning of some\nnode tests is dependent on the axis.</p>\n\n<p>The initial node-set is filtered by the first predicate to generate\na new node-set; this new node-set is then filtered using the second\npredicate, and so on. The final node-set is the node-set selected by\nthe location step. The axis affects how the expression in each\npredicate is evaluated and so the semantics of a predicate is defined\nwith respect to an axis.  See <a href=\"#predicates\">[<b>2.4 Predicates</b>]</a>.</p>\n\n<h5>Location Steps</h5>\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Step\"></a>[4]   </td><td>Step</td><td>   ::=   </td><td><a href=\"#NT-AxisSpecifier\">AxisSpecifier</a>\n<a href=\"#NT-NodeTest\">NodeTest</a>\n<a href=\"#NT-Predicate\">Predicate</a>*</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AbbreviatedStep\">AbbreviatedStep</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AxisSpecifier\"></a>[5]   </td><td>AxisSpecifier</td><td>   ::=   </td><td><a href=\"#NT-AxisName\">AxisName</a> '::'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AbbreviatedAxisSpecifier\">AbbreviatedAxisSpecifier</a>\n</td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"axes\"></a>2.2 Axes</h3>\n\n<p>The following axes are available:</p>\n\n<ul>\n\n<li>\n<p>the <code>child</code> axis contains the children of the\ncontext node</p>\n</li>\n\n<li>\n<p>the <code>descendant</code> axis contains the descendants of\nthe context node; a descendant is a child or a child of a child and so\non; thus the descendant axis never contains attribute or namespace\nnodes</p>\n</li>\n\n<li>\n<p>the <code>parent</code> axis contains the <a href=\"#dt-parent\">parent</a> of the context node, if there is\none</p>\n</li>\n\n<li>\n<p>the <code>ancestor</code> axis contains the ancestors of the\ncontext node; the ancestors of the context node consist of the\n<a href=\"#dt-parent\">parent</a> of context node and the\nparent's parent and so on; thus, the ancestor axis will always include\nthe root node, unless the context node is the root node</p>\n</li>\n\n<li>\n<p>the <code>following-sibling</code> axis contains all the\nfollowing siblings of the context node; if the\ncontext node is an attribute node or namespace node, the\n<code>following-sibling</code> axis is empty</p>\n</li>\n\n<li>\n<p>the <code>preceding-sibling</code> axis contains all the\npreceding siblings of the context node; if the context node is an\nattribute node or namespace node, the <code>preceding-sibling</code>\naxis is empty</p>\n</li>\n\n<li>\n<p>the <code>following</code> axis contains all nodes in the\nsame document as the context node that are after the context node in\ndocument order, excluding any descendants and excluding attribute\nnodes and namespace nodes</p>\n</li>\n\n<li>\n<p>the <code>preceding</code> axis contains all nodes in the\nsame document as the context node that are before the context node in\ndocument order, excluding any ancestors and excluding attribute nodes\nand namespace nodes</p>\n</li>\n\n<li>\n<p>the <code>attribute</code> axis contains the attributes of\nthe context node; the axis will be empty unless the context node is an\nelement</p>\n</li>\n\n<li>\n<p>the <code>namespace</code> axis contains the namespace nodes\nof the context node; the axis will be empty unless the context node\nis an element</p>\n</li>\n\n<li>\n<p>the <code>self</code> axis contains just the context node\nitself</p>\n</li>\n\n<li>\n<p>the <code>descendant-or-self</code> axis contains the context\nnode and the descendants of the context node</p>\n</li>\n\n<li>\n<p>the <code>ancestor-or-self</code> axis contains the context\nnode and the ancestors of the context node; thus, the ancestor axis\nwill always include the root node</p>\n</li>\n\n</ul>\n\n<blockquote>\n<b>NOTE: </b>The <code>ancestor</code>, <code>descendant</code>,\n<code>following</code>, <code>preceding</code> and <code>self</code>\naxes partition a document (ignoring attribute and namespace nodes):\nthey do not overlap and together they contain all the nodes in the\ndocument.</blockquote>\n\n<h5>Axes</h5>\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AxisName\"></a>[6]   </td><td>AxisName</td><td>   ::=   </td><td>'ancestor'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'ancestor-or-self'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'attribute'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'child'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'descendant'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'descendant-or-self'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'following'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'following-sibling'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'namespace'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'parent'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'preceding'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'preceding-sibling'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'self'</td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"node-tests\"></a>2.3 Node Tests</h3>\n\n<p>\n<a name=\"dt-principal-node-type\"></a>Every axis has a <b>principal node type</b>.  If an axis\ncan contain elements, then the principal node type is element;\notherwise, it is the type of the nodes that the axis can\ncontain. Thus,</p>\n\n<ul>\n\n<li>For the attribute axis, the principal node type is attribute.</li>\n\n<li>For the namespace axis, the principal node type is namespace.</li>\n\n<li>For other axes, the principal node type is element.</li>\n\n</ul>\n\n<p>A node test that is a <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a>\nis true if and only if the type of the node (see <a href=\"#data-model\">[<b>5 Data Model</b>]</a>)\nis the principal node type and has\nan <a href=\"#dt-expanded-name\">expanded-name</a> equal to\nthe <a href=\"#dt-expanded-name\">expanded-name</a> specified\nby the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a>.  For example,\n<code>child::para</code> selects the <code>para</code> element\nchildren of the context node; if the context node has no\n<code>para</code> children, it will select an empty set of nodes.\n<code>attribute::href</code> selects the <code>href</code> attribute\nof the context node; if the context node has no <code>href</code>\nattribute, it will select an empty set of nodes.</p>\n\n<p>A <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> in the node test is\nexpanded into an <a href=\"#dt-expanded-name\">expanded-name</a> using the namespace\ndeclarations from the expression context.  This is the same way\nexpansion is done for element type names in start and end-tags except\nthat the default namespace declared with <code>xmlns</code> is not\nused: if the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> does not have\na prefix, then the namespace URI is null (this is the same way\nattribute names are expanded).  It is an error if the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> has a prefix for which there is\nno namespace declaration in the expression context.</p>\n\n<p>A node test <code>*</code> is true for any node of the principal\nnode type.  For example, <code>child::*</code> will select all element\nchildren of the context node, and <code>attribute::*</code> will\nselect all attributes of the context node.</p>\n\n<p>A node test can have the form <a href=\"http://www.w3.org/TR/REC-xml-names#NT-NCName\">NCName</a><code>:*</code>.  In this\ncase, the prefix is expanded in the same way as with a <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a>, using the context namespace\ndeclarations.  It is an error if there is no namespace declaration for\nthe prefix in the expression context.  The node test will be true for\nany node of the principal type whose <a href=\"#dt-expanded-name\">expanded-name</a> has the namespace URI\nto which the prefix expands, regardless of the local part of the\nname.</p>\n\n<p>The node test <code>text()</code> is true for any text node. For\nexample, <code>child::text()</code> will select the text node\nchildren of the context node.  Similarly, the node test\n<code>comment()</code> is true for any comment node, and the node test\n<code>processing-instruction()</code> is true for any processing\ninstruction. The <code>processing-instruction()</code> test may have\nan argument that is <a href=\"#NT-Literal\">Literal</a>; in this case, it\nis true for any processing instruction that has a name equal to the\nvalue of the <a href=\"#NT-Literal\">Literal</a>.</p>\n\n<p>A node test <code>node()</code> is true for any node of any type\nwhatsoever.</p>\n\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-NodeTest\"></a>[7]   </td><td>NodeTest</td><td>   ::=   </td><td><a href=\"#NT-NameTest\">NameTest</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-NodeType\">NodeType</a> '(' ')'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'processing-instruction' '(' <a href=\"#NT-Literal\">Literal</a> ')'</td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"predicates\"></a>2.4 Predicates</h3>\n\n<p>An axis is either a forward axis or a reverse axis.  An axis that\nonly ever contains the context node or nodes that are after the\ncontext node in <a href=\"#dt-document-order\">document\norder</a> is a forward axis.  An axis that only ever contains\nthe context node or nodes that are before the context node in <a href=\"#dt-document-order\">document order</a> is a reverse axis.\nThus, the ancestor, ancestor-or-self, preceding, and preceding-sibling\naxes are reverse axes; all other axes are forward axes. Since the self\naxis always contains at most one node, it makes no difference whether\nit is a forward or reverse axis.  <a name=\"dt-proximity-position\"></a>The <b>proximity position</b> of a\nmember of a node-set with respect to an axis is defined to be the\nposition of the node in the node-set ordered in document order if the\naxis is a forward axis and ordered in reverse document order if the\naxis is a reverse axis. The first position is 1.</p>\n\n<p>A predicate filters a node-set with respect to an axis to produce a\nnew node-set.  For each node in the node-set to be filtered, the <a href=\"#NT-PredicateExpr\">PredicateExpr</a> is evaluated with that node\nas the context node, with the number of nodes in the node-set as the\ncontext size, and with the <a href=\"#dt-proximity-position\">proximity position</a> of the node\nin the node-set with respect to the axis as the context position; if\n<a href=\"#NT-PredicateExpr\">PredicateExpr</a> evaluates to true for\nthat node, the node is included in the new node-set; otherwise, it is\nnot included.</p>\n\n<p>A <a href=\"#NT-PredicateExpr\">PredicateExpr</a> is evaluated by\nevaluating the <a href=\"#NT-Expr\">Expr</a> and converting the result\nto a boolean.  If the result is a number, the result will be converted\nto true if the number is equal to the context position and will be\nconverted to false otherwise; if the result is not a number, then the\nresult will be converted as if by a call to the\n<b><a href=\"#function-boolean\">boolean</a></b> function.  Thus a location path\n<code>para[3]</code> is equivalent to\n<code>para[position()=3]</code>.</p>\n\n<h5>Predicates</h5>\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Predicate\"></a>[8]   </td><td>Predicate</td><td>   ::=   </td><td>'[' <a href=\"#NT-PredicateExpr\">PredicateExpr</a> ']'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-PredicateExpr\"></a>[9]   </td><td>PredicateExpr</td><td>   ::=   </td><td><a href=\"#NT-Expr\">Expr</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"path-abbrev\"></a>2.5 Abbreviated Syntax</h3>\n\n<p>Here are some examples of location paths using abbreviated\nsyntax:</p>\n\n<ul>\n\n<li>\n<p>\n<code>para</code> selects the <code>para</code> element children of\nthe context node</p>\n</li>\n\n<li>\n<p>\n<code>*</code> selects all element children of the\ncontext node</p>\n</li>\n\n<li>\n<p>\n<code>text()</code> selects all text node children of the\ncontext node</p>\n</li>\n\n<li>\n<p>\n<code>@name</code> selects the <code>name</code> attribute of\nthe context node</p>\n</li>\n\n<li>\n<p>\n<code>@*</code> selects all the attributes of the\ncontext node</p>\n</li>\n\n<li>\n<p>\n<code>para[1]</code> selects the first <code>para</code> child of\nthe context node</p>\n</li>\n\n<li>\n<p>\n<code>para[last()]</code> selects the last <code>para</code> child\nof the context node</p>\n</li>\n\n<li>\n<p>\n<code>*/para</code> selects all <code>para</code> grandchildren of\nthe context node</p>\n</li>\n\n<li>\n<p>\n<code>/doc/chapter[5]/section[2]</code> selects the second\n<code>section</code> of the fifth <code>chapter</code> of the\n<code>doc</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>chapter//para</code> selects the <code>para</code> element\ndescendants of the <code>chapter</code> element children of the\ncontext node</p>\n</li>\n\n<li>\n<p>\n<code>//para</code> selects all the <code>para</code> descendants of\nthe document root and thus selects all <code>para</code> elements in the\nsame document as the context node</p>\n</li>\n\n<li>\n<p>\n<code>//olist/item</code> selects all the <code>item</code>\nelements in the same document as the context node that have an\n<code>olist</code> parent</p>\n</li>\n\n<li>\n<p>\n<code>.</code> selects the context node</p>\n</li>\n\n<li>\n<p>\n<code>.//para</code> selects the <code>para</code> element\ndescendants of the context node</p>\n</li>\n\n<li>\n<p>\n<code>..</code> selects the parent of the context node</p>\n</li>\n\n<li>\n<p>\n<code>../@lang</code> selects the <code>lang</code> attribute\nof the parent of the context node</p>\n</li>\n\n<li>\n<p>\n<code>para[@type=\"warning\"]</code> selects all <code>para</code>\nchildren of the context node that have a <code>type</code> attribute with\nvalue <code>warning</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>para[@type=\"warning\"][5]</code> selects the fifth\n<code>para</code> child of the context node that has a <code>type</code>\nattribute with value <code>warning</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>para[5][@type=\"warning\"]</code> selects the fifth\n<code>para</code> child of the context node if that child has a\n<code>type</code> attribute with value <code>warning</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>chapter[title=\"Introduction\"]</code> selects the\n<code>chapter</code> children of the context node that have one or\nmore <code>title</code> children with <a href=\"#dt-string-value\">string-value</a> equal to\n<code>Introduction</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>chapter[title]</code> selects the <code>chapter</code>\nchildren of the context node that have one or more <code>title</code>\nchildren</p>\n</li>\n\n<li>\n<p>\n<code>employee[@secretary and @assistant]</code> selects all\nthe <code>employee</code> children of the context node that have both a\n<code>secretary</code> attribute and an <code>assistant</code>\nattribute</p>\n</li>\n\n</ul>\n\n<p>The most important abbreviation is that <code>child::</code> can be\nomitted from a location step.  In effect, <code>child</code> is the\ndefault axis.  For example, a location path <code>div/para</code> is\nshort for <code>child::div/child::para</code>.</p>\n\n<p>There is also an abbreviation for attributes:\n<code>attribute::</code> can be abbreviated to <code>@</code>. For\nexample, a location path <code>para[@type=\"warning\"]</code> is short\nfor <code>child::para[attribute::type=\"warning\"]</code> and so selects\n<code>para</code> children with a <code>type</code> attribute with\nvalue equal to <code>warning</code>.</p>\n\n<p>\n<code>//</code> is short for\n<code>/descendant-or-self::node()/</code>.  For example,\n<code>//para</code> is short for\n<code>/descendant-or-self::node()/child::para</code> and so will\nselect any <code>para</code> element in the document (even a\n<code>para</code> element that is a document element will be selected\nby <code>//para</code> since the document element node is a child of\nthe root node); <code>div//para</code> is short for\n<code>div/descendant-or-self::node()/child::para</code> and so\nwill select all <code>para</code> descendants of <code>div</code>\nchildren.</p>\n\n<blockquote>\n<b>NOTE: </b>The location path <code>//para[1]</code> does\n<i>not</i> mean the same as the location path\n<code>/descendant::para[1]</code>.  The latter selects the first\ndescendant <code>para</code> element; the former selects all descendant\n<code>para</code> elements that are the first <code>para</code>\nchildren of their parents.</blockquote>\n\n<p>A location step of <code>.</code> is short for\n<code>self::node()</code>. This is particularly useful in\nconjunction with <code>//</code>. For example, the location path\n<code>.//para</code> is short for</p>\n\n<pre>self::node()/descendant-or-self::node()/child::para</pre>\n\n<p>and so will select all <code>para</code> descendant elements of the\ncontext node.</p>\n\n<p>Similarly, a location step of <code>..</code> is short for\n<code>parent::node()</code>. For example, <code>../title</code> is\nshort for <code>parent::node()/child::title</code> and so will\nselect the <code>title</code> children of the parent of the context\nnode.</p>\n\n<h5>Abbreviations</h5>\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AbbreviatedAbsoluteLocationPath\"></a>[10]   </td><td>AbbreviatedAbsoluteLocationPath</td><td>   ::=   </td><td>'//' <a href=\"#NT-RelativeLocationPath\">RelativeLocationPath</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AbbreviatedRelativeLocationPath\"></a>[11]   </td><td>AbbreviatedRelativeLocationPath</td><td>   ::=   </td><td><a href=\"#NT-RelativeLocationPath\">RelativeLocationPath</a> '//' <a href=\"#NT-Step\">Step</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AbbreviatedStep\"></a>[12]   </td><td>AbbreviatedStep</td><td>   ::=   </td><td>'.'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| '..'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AbbreviatedAxisSpecifier\"></a>[13]   </td><td>AbbreviatedAxisSpecifier</td><td>   ::=   </td><td>'@'?</td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n\n\n<h2>\n<a name=\"section-Expressions\"></a>3 Expressions</h2>\n\n\n<h3>\n<a name=\"section-Basics\"></a>3.1 Basics</h3>\n\n<p>A <a href=\"#NT-VariableReference\">VariableReference</a> evaluates\nto the value to which the variable name is bound in the set of\nvariable bindings in the context.  It is an error if the variable name\nis not bound to any value in the set of variable bindings in the\nexpression context.</p>\n\n<p>Parentheses may be used for grouping.</p>\n\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Expr\"></a>[14]   </td><td>Expr</td><td>   ::=   </td><td><a href=\"#NT-OrExpr\">OrExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-PrimaryExpr\"></a>[15]   </td><td>PrimaryExpr</td><td>   ::=   </td><td><a href=\"#NT-VariableReference\">VariableReference</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| '(' <a href=\"#NT-Expr\">Expr</a> ')'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-Literal\">Literal</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-Number\">Number</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-FunctionCall\">FunctionCall</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"section-Function-Calls\"></a>3.2 Function Calls</h3>\n\n<p>A <a href=\"#NT-FunctionCall\">FunctionCall</a> expression is\nevaluated by using the <a href=\"#NT-FunctionName\">FunctionName</a> to\nidentify a function in the expression evaluation context function\nlibrary, evaluating each of the <a href=\"#NT-Argument\">Argument</a>s,\nconverting each argument to the type required by the function, and\nfinally calling the function, passing it the converted arguments.  It\nis an error if the number of arguments is wrong or if an argument\ncannot be converted to the required type.  The result of the <a href=\"#NT-FunctionCall\">FunctionCall</a> expression is the result\nreturned by the function.</p>\n\n<p>An argument is converted to type string as if by calling the\n<b><a href=\"#function-string\">string</a></b> function.  An argument is converted to\ntype number as if by calling the <b><a href=\"#function-number\">number</a></b> function.\nAn argument is converted to type boolean as if by calling the\n<b><a href=\"#function-boolean\">boolean</a></b> function.  An argument that is not of\ntype node-set cannot be converted to a node-set.</p>\n\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-FunctionCall\"></a>[16]   </td><td>FunctionCall</td><td>   ::=   </td><td><a href=\"#NT-FunctionName\">FunctionName</a> '(' ( <a href=\"#NT-Argument\">Argument</a> ( ',' <a href=\"#NT-Argument\">Argument</a> )* )? ')'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Argument\"></a>[17]   </td><td>Argument</td><td>   ::=   </td><td><a href=\"#NT-Expr\">Expr</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"node-sets\"></a>3.3 Node-sets</h3>\n\n<p>A location path can be used as an expression.  The expression\nreturns the set of nodes selected by the path.</p>\n\n<p>The <code>|</code> operator computes the union of its operands,\nwhich must be node-sets.</p>\n\n<p>\n<a href=\"#NT-Predicate\">Predicate</a>s are used to filter\nexpressions in the same way that they are used in location paths. It\nis an error if the expression to be filtered does not evaluate to a\nnode-set.  The <a href=\"#NT-Predicate\">Predicate</a> filters the\nnode-set with respect to the child axis.</p>\n\n<blockquote>\n<b>NOTE: </b>The meaning of a <a href=\"#NT-Predicate\">Predicate</a>\ndepends crucially on which axis applies. For example,\n<code>preceding::foo[1]</code> returns the first <code>foo</code>\nelement in <i>reverse document order</i>, because the axis that\napplies to the <code>[1]</code> predicate is the preceding axis; by\ncontrast, <code>(preceding::foo)[1]</code> returns the first\n<code>foo</code> element in <i>document order</i>, because the\naxis that applies to the <code>[1]</code> predicate is the child\naxis.</blockquote>\n\n<p>The <code>/</code> and <code>//</code> operators compose an\nexpression and a relative location path.  It is an error if the\nexpression does not evaluate to a node-set.  The <code>/</code>\noperator does composition in the same way as when <code>/</code> is\nused in a location path. As in location paths, <code>//</code> is\nshort for <code>/descendant-or-self::node()/</code>.</p>\n\n<p>There are no types of objects that can be converted to node-sets.</p>\n\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-UnionExpr\"></a>[18]   </td><td>UnionExpr</td><td>   ::=   </td><td><a href=\"#NT-PathExpr\">PathExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-UnionExpr\">UnionExpr</a> '|' <a href=\"#NT-PathExpr\">PathExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-PathExpr\"></a>[19]   </td><td>PathExpr</td><td>   ::=   </td><td><a href=\"#NT-LocationPath\">LocationPath</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-FilterExpr\">FilterExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-FilterExpr\">FilterExpr</a> '/' <a href=\"#NT-RelativeLocationPath\">RelativeLocationPath</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-FilterExpr\">FilterExpr</a> '//' <a href=\"#NT-RelativeLocationPath\">RelativeLocationPath</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-FilterExpr\"></a>[20]   </td><td>FilterExpr</td><td>   ::=   </td><td><a href=\"#NT-PrimaryExpr\">PrimaryExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-FilterExpr\">FilterExpr</a> <a href=\"#NT-Predicate\">Predicate</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"booleans\"></a>3.4 Booleans</h3>\n\n<p>An object of type boolean can have one of two values, true and\nfalse.</p>\n\n<p>An <code>or</code> expression is evaluated by evaluating each\noperand and converting its value to a boolean as if by a call to the\n<b><a href=\"#function-boolean\">boolean</a></b> function.  The result is true if either\nvalue is true and false otherwise.  The right operand is not evaluated\nif the left operand evaluates to true.</p>\n\n<p>An <code>and</code> expression is evaluated by evaluating each\noperand and converting its value to a boolean as if by a call to the\n<b><a href=\"#function-boolean\">boolean</a></b> function.  The result is true if both\nvalues are true and false otherwise.  The right operand is not\nevaluated if the left operand evaluates to false.</p>\n\n<p>An <a href=\"#NT-EqualityExpr\">EqualityExpr</a> (that is not just\na <a href=\"#NT-RelationalExpr\">RelationalExpr</a>) or a <a href=\"#NT-RelationalExpr\">RelationalExpr</a> (that is not just an <a href=\"#NT-AdditiveExpr\">AdditiveExpr</a>) is evaluated by comparing the\nobjects that result from evaluating the two operands.  Comparison of\nthe resulting objects is defined in the following three paragraphs.\nFirst, comparisons that involve node-sets are defined in terms of\ncomparisons that do not involve node-sets; this is defined uniformly\nfor <code>=</code>, <code>!=</code>, <code> =</code>,\n<code> </code>, <code> =</code> and <code> </code>.  Second,\ncomparisons that do not involve node-sets are defined for\n<code>=</code> and <code>!=</code>.  Third, comparisons that do not\ninvolve node-sets are defined for <code> =</code>,\n<code> </code>, <code> =</code> and <code> </code>.</p>\n\n<p>If both objects to be compared are node-sets, then the comparison\nwill be true if and only if there is a node in the first node-set and\na node in the second node-set such that the result of performing the\ncomparison on the <a href=\"#dt-string-value\">string-value</a>s of the two nodes is\ntrue.  If one object to be compared is a node-set and the other is a\nnumber, then the comparison will be true if and only if there is a\nnode in the node-set such that the result of performing the comparison\non the number to be compared and on the result of converting the\n<a href=\"#dt-string-value\">string-value</a> of that node to\na number using the <b><a href=\"#function-number\">number</a></b> function is true.  If\none object to be compared is a node-set and the other is a string,\nthen the comparison will be true if and only if there is a node in the\nnode-set such that the result of performing the comparison on the\n<a href=\"#dt-string-value\">string-value</a> of the node and\nthe other string is true. If one object to be compared is a node-set\nand the other is a boolean, then the comparison will be true if and\nonly if the result of performing the comparison on the boolean and on\nthe result of converting the node-set to a boolean using the\n<b><a href=\"#function-boolean\">boolean</a></b> function is true.</p>\n\n<p>When neither object to be compared is a node-set and the operator\nis <code>=</code> or <code>!=</code>, then the objects are compared by\nconverting them to a common type as follows and then comparing them.\nIf at least one object to be compared is a boolean, then each object\nto be compared is converted to a boolean as if by applying the\n<b><a href=\"#function-boolean\">boolean</a></b> function.  Otherwise, if at least one\nobject to be compared is a number, then each object to be compared is\nconverted to a number as if by applying the\n<b><a href=\"#function-number\">number</a></b> function.  Otherwise, both objects to be\ncompared are converted to strings as if by applying the\n<b><a href=\"#function-string\">string</a></b> function.  The <code>=</code> comparison\nwill be true if and only if the objects are equal; the <code>!=</code>\ncomparison will be true if and only if the objects are not equal.\nNumbers are compared for equality according to IEEE 754 <a href=\"#IEEE754\">[IEEE 754]</a>.  Two booleans are equal if either both are true or\nboth are false.  Two strings are equal if and only if they consist of\nthe same sequence of UCS characters.</p>\n\n<blockquote>\n<b>NOTE: </b>If <code>$x</code> is bound to a node-set, then\n<code>$x=\"foo\"</code> does not mean the same as\n<code>not($x!=\"foo\")</code>: the former is true if and only if\n<i>some</i> node in <code>$x</code> has the string-value\n<code>foo</code>; the latter is true if and only if <i>all</i>\nnodes in <code>$x</code> have the string-value\n<code>foo</code>.</blockquote>\n\n<p>When neither object to be compared is a node-set and the operator\nis <code> =</code>, <code> </code>, <code> =</code> or\n<code> </code>, then the objects are compared by converting both\nobjects to numbers and comparing the numbers according to IEEE 754.\nThe <code> </code> comparison will be true if and only if the first\nnumber is less than the second number.  The <code> =</code>\ncomparison will be true if and only if the first number is less than\nor equal to the second number.  The <code> </code> comparison will\nbe true if and only if the first number is greater than the second\nnumber.  The <code> =</code> comparison will be true if and only if\nthe first number is greater than or equal to the second number.</p>\n\n<blockquote>\n<b>NOTE: </b>\n\nWhen an XPath expression occurs in an XML document, any\n<code> </code> and <code> =</code> operators must be quoted\naccording to XML 1.0 rules by using, for example,\n<code> lt;</code> and <code> lt;=</code>. In the following\nexample the value of the <code>test</code> attribute is an XPath\nexpression:\n\n<pre> xsl:if test=\"@value  lt; 10\" ... /xsl:if </pre>\n\n</blockquote>\n\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-OrExpr\"></a>[21]   </td><td>OrExpr</td><td>   ::=   </td><td><a href=\"#NT-AndExpr\">AndExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-OrExpr\">OrExpr</a> 'or' <a href=\"#NT-AndExpr\">AndExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AndExpr\"></a>[22]   </td><td>AndExpr</td><td>   ::=   </td><td><a href=\"#NT-EqualityExpr\">EqualityExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AndExpr\">AndExpr</a> 'and' <a href=\"#NT-EqualityExpr\">EqualityExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-EqualityExpr\"></a>[23]   </td><td>EqualityExpr</td><td>   ::=   </td><td><a href=\"#NT-RelationalExpr\">RelationalExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-EqualityExpr\">EqualityExpr</a> '=' <a href=\"#NT-RelationalExpr\">RelationalExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-EqualityExpr\">EqualityExpr</a> '!=' <a href=\"#NT-RelationalExpr\">RelationalExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-RelationalExpr\"></a>[24]   </td><td>RelationalExpr</td><td>   ::=   </td><td><a href=\"#NT-AdditiveExpr\">AdditiveExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-RelationalExpr\">RelationalExpr</a> ' ' <a href=\"#NT-AdditiveExpr\">AdditiveExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-RelationalExpr\">RelationalExpr</a> ' ' <a href=\"#NT-AdditiveExpr\">AdditiveExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-RelationalExpr\">RelationalExpr</a> ' =' <a href=\"#NT-AdditiveExpr\">AdditiveExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-RelationalExpr\">RelationalExpr</a> ' =' <a href=\"#NT-AdditiveExpr\">AdditiveExpr</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n<blockquote>\n<b>NOTE: </b>The effect of the above grammar is that the order of\nprecedence is (lowest precedence first):\n\n<ul>\n\n<li>\n<p>\n<code>or</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>and</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>=</code>, <code>!=</code>\n</p>\n</li>\n\n<li>\n<p>\n<code> =</code>, <code> </code>, <code> =</code>,\n<code> </code>\n</p>\n</li>\n\n</ul>\n\nand the operators are all left associative.\n\nFor example, <code>3   2   1</code> is equivalent to <code>(3\n  2)   1</code>, which evaluates to false.\n\n</blockquote>\n\n\n\n\n<h3>\n<a name=\"numbers\"></a>3.5 Numbers</h3>\n\n<p>A number represents a floating-point number.  A number can have any\ndouble-precision 64-bit format IEEE 754 value <a href=\"#IEEE754\">[IEEE 754]</a>.\nThese include a special \"Not-a-Number\" (NaN) value,\npositive and negative infinity, and positive and negative zero.  See\n<a href=\"http://java.sun.com/docs/books/jls/html/4.doc.html#9208\">Section 4.2.3</a> of <a href=\"#JLS\">[JLS]</a> for a summary of the key\nrules of the IEEE 754 standard.</p>\n\n<p>The numeric operators convert their operands to numbers as if by\ncalling the <b><a href=\"#function-number\">number</a></b> function.</p>\n\n<p>The <code>+</code> operator performs addition.</p>\n\n<p>The <code>-</code> operator performs subtraction.</p>\n\n<blockquote>\n<b>NOTE: </b>Since XML allows <code>-</code> in names, the <code>-</code>\noperator typically needs to be preceded by whitespace.  For example,\n<code>foo-bar</code> evaluates to a node-set containing the child\nelements named <code>foo-bar</code>; <code>foo - bar</code> evaluates\nto the difference of the result of converting the <a href=\"#dt-string-value\">string-value</a> of the first\n<code>foo</code> child element to a number and the result of\nconverting the <a href=\"#dt-string-value\">string-value</a>\nof the first <code>bar</code> child to a number.</blockquote>\n \n<p>The <code>div</code> operator performs floating-point division\naccording to IEEE 754.</p>\n\n<p>The <code>mod</code> operator returns the remainder from a\ntruncating division.  For example,</p>\n\n<ul>\n<li>\n<p>\n<code>5 mod 2</code> returns <code>1</code>\n</p>\n</li>\n<li>\n<p>\n<code>5 mod -2</code> returns <code>1</code>\n</p>\n</li>\n<li>\n<p>\n<code>-5 mod 2</code> returns <code>-1</code>\n</p>\n</li>\n<li>\n<p>\n<code>-5 mod -2</code> returns <code>-1</code>\n</p>\n</li>\n</ul>\n\n<blockquote>\n<b>NOTE: </b>This is the same as the <code>%</code> operator in Java and\nECMAScript.</blockquote>\n\n<blockquote>\n<b>NOTE: </b>This is not the same as the IEEE 754 remainder operation, which\nreturns the remainder from a rounding division.</blockquote>\n\n<h5>Numeric Expressions</h5>\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-AdditiveExpr\"></a>[25]   </td><td>AdditiveExpr</td><td>   ::=   </td><td><a href=\"#NT-MultiplicativeExpr\">MultiplicativeExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AdditiveExpr\">AdditiveExpr</a> '+' <a href=\"#NT-MultiplicativeExpr\">MultiplicativeExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AdditiveExpr\">AdditiveExpr</a> '-' <a href=\"#NT-MultiplicativeExpr\">MultiplicativeExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-MultiplicativeExpr\"></a>[26]   </td><td>MultiplicativeExpr</td><td>   ::=   </td><td><a href=\"#NT-UnaryExpr\">UnaryExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-MultiplicativeExpr\">MultiplicativeExpr</a> <a href=\"#NT-MultiplyOperator\">MultiplyOperator</a> <a href=\"#NT-UnaryExpr\">UnaryExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-MultiplicativeExpr\">MultiplicativeExpr</a> 'div' <a href=\"#NT-UnaryExpr\">UnaryExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-MultiplicativeExpr\">MultiplicativeExpr</a> 'mod' <a href=\"#NT-UnaryExpr\">UnaryExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-UnaryExpr\"></a>[27]   </td><td>UnaryExpr</td><td>   ::=   </td><td><a href=\"#NT-UnionExpr\">UnionExpr</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| '-' <a href=\"#NT-UnaryExpr\">UnaryExpr</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n<h3>\n<a name=\"strings\"></a>3.6 Strings</h3>\n\n<p>Strings consist of a sequence of zero or more characters, where a\ncharacter is defined as in the XML Recommendation <a href=\"#XML\">[XML]</a>.\nA single character in XPath thus corresponds to a single Unicode\nabstract character with a single corresponding Unicode scalar value\n(see <a href=\"#UNICODE\">[Unicode]</a>); this is not the same thing as a 16-bit\nUnicode code value: the Unicode coded character representation for an\nabstract character with Unicode scalar value greater that U+FFFF is a\npair of 16-bit Unicode code values (a surrogate pair).  In many\nprogramming languages, a string is represented by a sequence of 16-bit\nUnicode code values; implementations of XPath in such languages must\ntake care to ensure that a surrogate pair is correctly treated as a\nsingle XPath character.</p>\n\n<blockquote>\n<b>NOTE: </b>It is possible in Unicode for there to be two strings that\nshould be treated as identical even though they consist of the\ndistinct sequences of Unicode abstract characters.  For example, some\naccented characters may be represented in either a precomposed or\ndecomposed form.  Therefore, XPath expressions may return unexpected\nresults unless both the characters in the XPath expression and in the\nXML document have been normalized into a canonical form.  See <a href=\"#CHARMOD\">[Character Model]</a>.</blockquote>\n\n\n\n\n<h3>\n<a name=\"exprlex\"></a>3.7 Lexical Structure</h3>\n\n<p>When tokenizing, the longest possible token is always returned.</p>\n\n<p>For readability, whitespace may be used in expressions even though not\nexplicitly allowed by the grammar: <a href=\"#NT-ExprWhitespace\">ExprWhitespace</a> may be freely added within\npatterns before or after any <a href=\"#NT-ExprToken\">ExprToken</a>.</p>\n\n<p>The following special tokenization rules must be applied in the\norder specified to disambiguate the <a href=\"#NT-ExprToken\">ExprToken</a> grammar:</p>\n\n<ul>\n\n<li>\n<p>If there is a preceding token and the preceding token is not\none of <code>@</code>, <code>::</code>, <code>(</code>,\n<code>[</code>, <code>,</code> or an <a href=\"#NT-Operator\">Operator</a>, then a <code>*</code> must be\nrecognized as a <a href=\"#NT-MultiplyOperator\">MultiplyOperator</a>\nand an <a href=\"http://www.w3.org/TR/REC-xml-names#NT-NCName\">NCName</a> must be\nrecognized as an <a href=\"#NT-OperatorName\">OperatorName</a>.</p>\n</li>\n\n<li>\n<p>If the character following an <a href=\"http://www.w3.org/TR/REC-xml-names#NT-NCName\">NCName</a> (possibly after intervening\n<a href=\"#NT-ExprWhitespace\">ExprWhitespace</a>) is <code>(</code>,\nthen the token must be recognized as a <a href=\"#NT-NodeType\">NodeType</a> or a <a href=\"#NT-FunctionName\">FunctionName</a>.</p>\n</li>\n\n<li>\n<p>If the two characters following an <a href=\"http://www.w3.org/TR/REC-xml-names#NT-NCName\">NCName</a> (possibly after intervening\n<a href=\"#NT-ExprWhitespace\">ExprWhitespace</a>) are <code>::</code>,\nthen the token must be recognized as an <a href=\"#NT-AxisName\">AxisName</a>.</p>\n</li>\n\n<li>\n<p>Otherwise, the token must not be recognized as a <a href=\"#NT-MultiplyOperator\">MultiplyOperator</a>, an <a href=\"#NT-OperatorName\">OperatorName</a>, a <a href=\"#NT-NodeType\">NodeType</a>, a <a href=\"#NT-FunctionName\">FunctionName</a>, or an <a href=\"#NT-AxisName\">AxisName</a>.</p>\n</li>\n\n</ul>\n\n<h5>Expression Lexical Structure</h5>\n<table class=\"scrap\">\n<tbody>\n<tr valign=\"baseline\">\n<td><a name=\"NT-ExprToken\"></a>[28]   </td><td>ExprToken</td><td>   ::=   </td><td>'(' | ')' | '[' | ']' | '.' | '..' | '@' | ',' | '::'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-NameTest\">NameTest</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-NodeType\">NodeType</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-Operator\">Operator</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-FunctionName\">FunctionName</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-AxisName\">AxisName</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-Literal\">Literal</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-Number\">Number</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-VariableReference\">VariableReference</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Literal\"></a>[29]   </td><td>Literal</td><td>   ::=   </td><td>'\"' [^\"]* '\"'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| \"'\" [^']* \"'\"</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Number\"></a>[30]   </td><td>Number</td><td>   ::=   </td><td><a href=\"#NT-Digits\">Digits</a> ('.' <a href=\"#NT-Digits\">Digits</a>?)?</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| '.' <a href=\"#NT-Digits\">Digits</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Digits\"></a>[31]   </td><td>Digits</td><td>   ::=   </td><td>[0-9]+</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-Operator\"></a>[32]   </td><td>Operator</td><td>   ::=   </td><td><a href=\"#NT-OperatorName\">OperatorName</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"#NT-MultiplyOperator\">MultiplyOperator</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| '/' | '//' | '|' | '+' | '-' | '=' | '!=' | ' ' | ' =' | ' ' | ' ='</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-OperatorName\"></a>[33]   </td><td>OperatorName</td><td>   ::=   </td><td>'and' | 'or' | 'mod' | 'div'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-MultiplyOperator\"></a>[34]   </td><td>MultiplyOperator</td><td>   ::=   </td><td>'*'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-FunctionName\"></a>[35]   </td><td>FunctionName</td><td>   ::=   </td><td>\n<a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a>\n- <a href=\"#NT-NodeType\">NodeType</a>\n</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-VariableReference\"></a>[36]   </td><td>VariableReference</td><td>   ::=   </td><td>'$' <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-NameTest\"></a>[37]   </td><td>NameTest</td><td>   ::=   </td><td>'*'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"http://www.w3.org/TR/REC-xml-names#NT-NCName\">NCName</a> ':' '*'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a></td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-NodeType\"></a>[38]   </td><td>NodeType</td><td>   ::=   </td><td>'comment'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'text'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'processing-instruction'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td></td><td></td><td></td><td>| 'node'</td><td></td>\n</tr>\n<tr valign=\"baseline\">\n<td><a name=\"NT-ExprWhitespace\"></a>[39]   </td><td>ExprWhitespace</td><td>   ::=   </td><td><a href=\"http://www.w3.org/TR/REC-xml#NT-S\">S</a></td><td></td>\n</tr>\n</tbody>\n</table>\n\n\n\n\n\n\n<h2>\n<a name=\"corelib\"></a>4 Core Function Library</h2>\n\n<p>This section describes functions that XPath implementations must\nalways include in the function library that is used to evaluate\nexpressions.</p>\n\n<p>Each function in the function library is specified using a function\nprototype, which gives the return type, the name of the function, and\nthe type of the arguments.  If an argument type is followed by a\nquestion mark, then the argument is optional; otherwise, the argument\nis required.</p>\n\n\n<h3>\n<a name=\"section-Node-Set-Functions\"></a>4.1 Node Set Functions</h3>\n\n<p>\n<a name=\"function-last\"><b>Function: </b><i>number</i> <b>last</b>()</a>\n</p>\n\n<p>The <b><a href=\"#function-last\">last</a></b> function returns a number equal to\nthe <a href=\"#dt-context-size\">context size</a> from the\nexpression evaluation context.</p>\n\n<p>\n<a name=\"function-position\"><b>Function: </b><i>number</i> <b>position</b>()</a>\n</p>\n\n<p>The <b><a href=\"#function-position\">position</a></b> function returns a number equal to\nthe <a href=\"#dt-context-position\">context position</a> from\nthe expression evaluation context.</p>\n\n<p>\n<a name=\"function-count\"><b>Function: </b><i>number</i> <b>count</b>(<i>node-set</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-count\">count</a></b> function returns the number of nodes in the\nargument node-set.</p>\n\n<p>\n<a name=\"function-id\"><b>Function: </b><i>node-set</i> <b>id</b>(<i>object</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-id\">id</a></b> function selects elements by their\nunique ID (see <a href=\"#unique-id\">[<b>5.2.1 Unique IDs</b>]</a>).  When the argument to\n<b><a href=\"#function-id\">id</a></b> is of type node-set, then the result is the\nunion of the result of applying <b><a href=\"#function-id\">id</a></b> to the\n<a href=\"#dt-string-value\">string-value</a> of each of the\nnodes in the argument node-set.  When the argument to\n<b><a href=\"#function-id\">id</a></b> is of any other type, the argument is\nconverted to a string as if by a call to the\n<b><a href=\"#function-string\">string</a></b> function; the string is split into a\nwhitespace-separated list of tokens (whitespace is any sequence of\ncharacters matching the production <a href=\"http://www.w3.org/TR/REC-xml#NT-S\">S</a>);\nthe result is a node-set containing the elements in the same document\nas the context node that have a unique ID equal to any of the tokens\nin the list.</p>\n\n<ul>\n<li>\n<p>\n<code>id(\"foo\")</code> selects the element with unique ID\n<code>foo</code>\n</p>\n</li>\n<li>\n<p>\n<code>id(\"foo\")/child::para[position()=5]</code> selects\nthe fifth <code>para</code> child of the element with unique ID\n<code>foo</code>\n</p>\n</li>\n</ul>\n\n<p>\n<a name=\"function-local-name\"><b>Function: </b><i>string</i> <b>local-name</b>(<i>node-set</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-local-name\">local-name</a></b> function returns the local part\nof the <a href=\"#dt-expanded-name\">expanded-name</a> of the\nnode in the argument node-set that is first in <a href=\"#dt-document-order\">document order</a>. If the argument\nnode-set is empty or the first node has no <a href=\"#dt-expanded-name\">expanded-name</a>, an empty string is\nreturned.  If the argument is omitted, it defaults to a node-set with\nthe context node as its only member.</p>\n\n<p>\n<a name=\"function-namespace-uri\"><b>Function: </b><i>string</i> <b>namespace-uri</b>(<i>node-set</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-namespace-uri\">namespace-uri</a></b> function returns the\nnamespace URI of the <a href=\"#dt-expanded-name\">expanded-name</a> of the node in the\nargument node-set that is first in <a href=\"#dt-document-order\">document order</a>. If the argument\nnode-set is empty, the first node has no <a href=\"#dt-expanded-name\">expanded-name</a>, or the namespace URI\nof the <a href=\"#dt-expanded-name\">expanded-name</a> is\nnull, an empty string is returned.  If the argument is omitted, it\ndefaults to a node-set with the context node as its only member.</p>\n\n<blockquote>\n<b>NOTE: </b>The string returned by the\n<b><a href=\"#function-namespace-uri\">namespace-uri</a></b> function will be empty except for\nelement nodes and attribute nodes.</blockquote>\n\n<p>\n<a name=\"function-name\"><b>Function: </b><i>string</i> <b>name</b>(<i>node-set</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-name\">name</a></b> function returns a string containing\na <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> representing the\n<a href=\"#dt-expanded-name\">expanded-name</a> of the node in\nthe argument node-set that is first in <a href=\"#dt-document-order\">document order</a>. The <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> must represent the <a href=\"#dt-expanded-name\">expanded-name</a> with respect to the\nnamespace declarations in effect on the node whose <a href=\"#dt-expanded-name\">expanded-name</a> is being represented.\nTypically, this will be the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> that occurred in the XML\nsource.  This need not be the case if there are namespace declarations\nin effect on the node that associate multiple prefixes with the same\nnamespace.  However, an implementation may include information about\nthe original prefix in its representation of nodes; in this case, an\nimplementation can ensure that the returned string is always the same\nas the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> used in the XML\nsource. If the argument node-set is empty or the first node has no\n<a href=\"#dt-expanded-name\">expanded-name</a>, an empty\nstring is returned.  If the argument it omitted, it defaults to a\nnode-set with the context node as its only member.</p>\n\n<blockquote>\n<b>NOTE: </b>The string returned by the <b><a href=\"#function-name\">name</a></b> function\nwill be the same as the string returned by the\n<b><a href=\"#function-local-name\">local-name</a></b> function except for element nodes and\nattribute nodes.</blockquote>\n\n\n\n\n<h3>\n<a name=\"section-String-Functions\"></a>4.2 String Functions</h3>\n\n<p>\n<a name=\"function-string\"><b>Function: </b><i>string</i> <b>string</b>(<i>object</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-string\">string</a></b> function converts an object to a string\nas follows:</p>\n\n<ul>\n\n<li>\n<p>A node-set is converted to a string by returning the <a href=\"#dt-string-value\">string-value</a> of the node in the\nnode-set that is first in <a href=\"#dt-document-order\">document\norder</a>.  If the node-set is empty, an empty string is\nreturned.</p>\n</li>\n\n<li>\n<p>A number is converted to a string as follows</p>\n\n<ul>\n\n<li>\n<p>NaN is converted to the string <code>NaN</code>\n</p>\n</li>\n\n<li>\n<p>positive zero is converted to the string\n<code>0</code>\n</p>\n</li>\n\n<li>\n<p>negative zero is converted to the string\n<code>0</code>\n</p>\n</li>\n\n<li>\n<p>positive infinity is converted to the string\n<code>Infinity</code>\n</p>\n</li>\n\n<li>\n<p>negative infinity is converted to the string\n<code>-Infinity</code>\n</p>\n</li>\n\n<li>\n<p>if the number is an integer, the number is represented in\ndecimal form as a <a href=\"#NT-Number\">Number</a> with no decimal\npoint and no leading zeros, preceded by a minus sign (<code>-</code>)\nif the number is negative</p>\n</li>\n\n<li>\n<p>otherwise, the number is represented in decimal form as a <a href=\"#NT-Number\">Number</a> including a decimal point with at least\none digit before the decimal point and at least one digit after the\ndecimal point, preceded by a minus sign (<code>-</code>) if the number\nis negative; there must be no leading zeros before the decimal point\napart possibly from the one required digit immediately before the\ndecimal point; beyond the one required digit after the decimal point\nthere must be as many, but only as many, more digits as are needed to\nuniquely distinguish the number from all other IEEE 754 numeric\nvalues.</p>\n</li>\n\n</ul>\n\n</li>\n\n<li>\n<p>The boolean false value is converted to the string\n<code>false</code>.  The boolean true value is converted to the\nstring <code>true</code>.</p>\n</li>\n\n<li>\n<p>An object of a type other than the four basic types is\nconverted to a string in a way that is dependent on that\ntype.</p>\n</li>\n\n</ul>\n\n<p>If the argument is omitted, it defaults to a node-set with the\ncontext node as its only member.</p>\n\n<blockquote>\n<b>NOTE: </b>The <code>string</code> function is not intended for\nconverting numbers into strings for presentation to users.  The\n<code>format-number</code> function and <code>xsl:number</code>\nelement in <a href=\"#XSLT\">[XSLT]</a> provide this\nfunctionality.</blockquote>\n\n<p>\n<a name=\"function-concat\"><b>Function: </b><i>string</i> <b>concat</b>(<i>string</i>, <i>string</i>, <i>string</i>*)</a>\n</p>\n\n<p>The <b><a href=\"#function-concat\">concat</a></b> function returns the concatenation of its\narguments.</p>\n\n<p>\n<a name=\"function-starts-with\"><b>Function: </b><i>boolean</i> <b>starts-with</b>(<i>string</i>, <i>string</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-starts-with\">starts-with</a></b> function returns true if the\nfirst argument string starts with the second argument string, and\notherwise returns false.</p>\n\n<p>\n<a name=\"function-contains\"><b>Function: </b><i>boolean</i> <b>contains</b>(<i>string</i>, <i>string</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-contains\">contains</a></b> function returns true if the first\nargument string contains the second argument string, and otherwise\nreturns false.</p>\n\n<p>\n<a name=\"function-substring-before\"><b>Function: </b><i>string</i> <b>substring-before</b>(<i>string</i>, <i>string</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-substring-before\">substring-before</a></b> function returns the substring\nof the first argument string that precedes the first occurrence of the\nsecond argument string in the first argument string, or the empty\nstring if the first argument string does not contain the second\nargument string.  For example,\n<code>substring-before(\"1999/04/01\",\"/\")</code> returns\n<code>1999</code>.</p>\n\n<p>\n<a name=\"function-substring-after\"><b>Function: </b><i>string</i> <b>substring-after</b>(<i>string</i>, <i>string</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-substring-after\">substring-after</a></b> function returns the\nsubstring of the first argument string that follows the first\noccurrence of the second argument string in the first argument string,\nor the empty string if the first argument string does not contain the\nsecond argument string. For example,\n<code>substring-after(\"1999/04/01\",\"/\")</code> returns\n<code>04/01</code>, and\n<code>substring-after(\"1999/04/01\",\"19\")</code> returns\n<code>99/04/01</code>.</p>\n\n<p>\n<a name=\"function-substring\"><b>Function: </b><i>string</i> <b>substring</b>(<i>string</i>, <i>number</i>, <i>number</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-substring\">substring</a></b> function returns the substring of the\nfirst argument starting at the position specified in the second\nargument with length specified in the third argument. For example,\n<code>substring(\"12345\",2,3)</code> returns <code>\"234\"</code>.\nIf the third argument is not specified, it returns\nthe substring starting at the position specified in the second\nargument and continuing to the end of the string. For example,\n<code>substring(\"12345\",2)</code> returns <code>\"2345\"</code>.</p>\n\n<p>More precisely, each character in the string (see <a href=\"#strings\">[<b>3.6 Strings</b>]</a>) is considered to have a numeric position: the\nposition of the first character is 1, the position of the second\ncharacter is 2 and so on.</p>\n\n<blockquote>\n<b>NOTE: </b>This differs from Java and ECMAScript, in which the\n<code>String.substring</code> method treats the position of the first\ncharacter as 0.</blockquote>\n\n<p>The returned substring contains those\ncharacters for which the position of the character is greater than or\nequal to the rounded value of the second argument and, if the third\nargument is specified, less than the sum of the rounded value of the\nsecond argument and the rounded value of the third argument; the\ncomparisons and addition used for the above follow the standard IEEE\n754 rules; rounding is done as if by a call to the\n<b><a href=\"#function-round\">round</a></b> function. The following examples illustrate\nvarious unusual cases:</p>\n\n<ul>\n\n<li>\n<p>\n<code>substring(\"12345\", 1.5, 2.6)</code> returns\n<code>\"234\"</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>substring(\"12345\", 0, 3)</code> returns\n<code>\"12\"</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>substring(\"12345\", 0 div 0, 3)</code> returns\n<code>\"\"</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>substring(\"12345\", 1, 0 div 0)</code> returns\n<code>\"\"</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>substring(\"12345\", -42, 1 div 0)</code> returns\n<code>\"12345\"</code>\n</p>\n</li>\n\n<li>\n<p>\n<code>substring(\"12345\", -1 div 0, 1 div 0)</code> returns\n<code>\"\"</code>\n</p>\n</li>\n\n</ul>\n\n<p>\n<a name=\"function-string-length\"><b>Function: </b><i>number</i> <b>string-length</b>(<i>string</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-string-length\">string-length</a></b> returns the number of\ncharacters in the string (see <a href=\"#strings\">[<b>3.6 Strings</b>]</a>).  If the\nargument is omitted, it defaults to the context node converted to a\nstring, in other words the <a href=\"#dt-string-value\">string-value</a> of the context node.</p>\n\n<p>\n<a name=\"function-normalize-space\"><b>Function: </b><i>string</i> <b>normalize-space</b>(<i>string</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-normalize-space\">normalize-space</a></b> function returns the argument\nstring with whitespace normalized by stripping leading and trailing\nwhitespace and replacing sequences of whitespace characters by a\nsingle space.  Whitespace characters are the same as those allowed by the <a href=\"http://www.w3.org/TR/REC-xml#NT-S\">S</a> production in XML.  If the argument is\nomitted, it defaults to the context node converted to a string, in\nother words the <a href=\"#dt-string-value\">string-value</a>\nof the context node.</p>\n\n<p>\n<a name=\"function-translate\"><b>Function: </b><i>string</i> <b>translate</b>(<i>string</i>, <i>string</i>, <i>string</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-translate\">translate</a></b> function returns the first\nargument string with occurrences of characters in the second argument\nstring replaced by the character at the corresponding position in the\nthird argument string.  For example,\n<code>translate(\"bar\",\"abc\",\"ABC\")</code> returns the string\n<code>BAr</code>.  If there is a character in the second argument\nstring with no character at a corresponding position in the third\nargument string (because the second argument string is longer than the\nthird argument string), then occurrences of that character in the\nfirst argument string are removed.  For example,\n<code>translate(\"--aaa--\",\"abc-\",\"ABC\")</code> returns\n<code>\"AAA\"</code>. If a character occurs more than once in the second\nargument string, then the first occurrence determines the replacement\ncharacter.  If the third argument string is longer than the second\nargument string, then excess characters are ignored.</p>\n\n<blockquote>\n<b>NOTE: </b>The <b><a href=\"#function-translate\">translate</a></b> function is not a sufficient\nsolution for case conversion in all languages.  A future version of\nXPath may provide additional functions for case conversion.</blockquote>\n\n\n\n\n<h3>\n<a name=\"section-Boolean-Functions\"></a>4.3 Boolean Functions</h3>\n\n<p>\n<a name=\"function-boolean\"><b>Function: </b><i>boolean</i> <b>boolean</b>(<i>object</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-boolean\">boolean</a></b> function converts its argument to a\nboolean as follows:</p>\n\n<ul>\n\n<li>\n<p>a number is true if and only if it is neither positive or\nnegative zero nor NaN</p>\n</li>\n\n<li>\n<p>a node-set is true if and only if it is non-empty</p>\n</li>\n\n<li>\n<p>a string is true if and only if its length is non-zero</p>\n</li>\n\n<li>\n<p>an object of a type other than the four basic types is\nconverted to a boolean in a way that is dependent on that\ntype</p>\n</li>\n\n</ul>\n\n<p>\n<a name=\"function-not\"><b>Function: </b><i>boolean</i> <b>not</b>(<i>boolean</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-not\">not</a></b> function returns true if its argument is\nfalse, and false otherwise.</p>\n\n<p>\n<a name=\"function-true\"><b>Function: </b><i>boolean</i> <b>true</b>()</a>\n</p>\n\n<p>The <b><a href=\"#function-true\">true</a></b> function returns true.</p>\n\n<p>\n<a name=\"function-false\"><b>Function: </b><i>boolean</i> <b>false</b>()</a>\n</p>\n\n<p>The <b><a href=\"#function-false\">false</a></b> function returns false.</p>\n\n<p>\n<a name=\"function-lang\"><b>Function: </b><i>boolean</i> <b>lang</b>(<i>string</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-lang\">lang</a></b> function returns true or false depending on\nwhether the language of the context node as specified by\n<code>xml:lang</code> attributes is the same as or is a sublanguage of\nthe language specified by the argument string.  The language of the\ncontext node is determined by the value of the <code>xml:lang</code>\nattribute on the context node, or, if the context node has no\n<code>xml:lang</code> attribute, by the value of the\n<code>xml:lang</code> attribute on the nearest ancestor of the context\nnode that has an <code>xml:lang</code> attribute.  If there is no such\nattribute, then <b><a href=\"#function-lang\">lang</a></b> returns false. If there is such an\nattribute, then <b><a href=\"#function-lang\">lang</a></b> returns true if the attribute\nvalue is equal to the argument ignoring case, or if there is some\nsuffix starting with <code>-</code> such that the attribute value is\nequal to the argument ignoring that suffix of the attribute value and\nignoring case. For example, <code>lang(\"en\")</code> would return true\nif the context node is any of these five elements:</p>\n\n<pre> para xml:lang=\"en\"/ \n div xml:lang=\"en\"  para/  /div \n para xml:lang=\"EN\"/ \n para xml:lang=\"en-us\"/ </pre>\n\n\n\n<h3>\n<a name=\"section-Number-Functions\"></a>4.4 Number Functions</h3>\n\n<p>\n<a name=\"function-number\"><b>Function: </b><i>number</i> <b>number</b>(<i>object</i>?)</a>\n</p>\n\n<p>The <b><a href=\"#function-number\">number</a></b> function converts its argument to a\nnumber as follows:</p>\n\n<ul>\n\n<li>\n<p>a string that consists of optional whitespace followed by an\noptional minus sign followed by a <a href=\"#NT-Number\">Number</a>\nfollowed by whitespace is converted to the IEEE 754 number that is\nnearest (according to the IEEE 754 round-to-nearest rule)\nto the mathematical value represented by the string; any other\nstring is converted to NaN</p>\n</li>\n\n<li>\n<p>boolean true is converted to 1; boolean false is converted to\n0</p>\n</li>\n\n<li>\n\n<p>a node-set is first converted to a string as if by a call to the\n<b><a href=\"#function-string\">string</a></b> function and then converted in the same way as a\nstring argument</p>\n\n</li>\n\n<li>\n<p>an object of a type other than the four basic types is\nconverted to a number in a way that is dependent on that\ntype</p>\n</li>\n\n</ul>\n\n<p>If the argument is omitted, it defaults to a node-set with the\ncontext node as its only member.</p>\n\n<blockquote>\n<b>NOTE: </b>The <b><a href=\"#function-number\">number</a></b> function should not be used\nfor conversion of numeric data occurring in an element in an XML\ndocument unless the element is of a type that represents numeric data\nin a language-neutral format (which would typically be transformed\ninto a language-specific format for presentation to a user). In\naddition, the <b><a href=\"#function-number\">number</a></b> function cannot be used\nunless the language-neutral format used by the element is consistent\nwith the XPath syntax for a <a href=\"#NT-Number\">Number</a>.</blockquote>\n\n<p>\n<a name=\"function-sum\"><b>Function: </b><i>number</i> <b>sum</b>(<i>node-set</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-sum\">sum</a></b> function returns the sum, for each\nnode in the argument node-set, of the result of converting the\n<a href=\"#dt-string-value\">string-value</a>s of the node to\na number.</p>\n\n<p>\n<a name=\"function-floor\"><b>Function: </b><i>number</i> <b>floor</b>(<i>number</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-floor\">floor</a></b> function returns the largest (closest to\npositive infinity) number that is not greater than the argument and\nthat is an integer.</p>\n\n<p>\n<a name=\"function-ceiling\"><b>Function: </b><i>number</i> <b>ceiling</b>(<i>number</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-ceiling\">ceiling</a></b> function returns the smallest (closest\nto negative infinity) number that is not less than the argument and\nthat is an integer.</p>\n\n<p>\n<a name=\"function-round\"><b>Function: </b><i>number</i> <b>round</b>(<i>number</i>)</a>\n</p>\n\n<p>The <b><a href=\"#function-round\">round</a></b> function returns the number that is\nclosest to the argument and that is an integer.  If there are two such\nnumbers, then the one that is closest to positive infinity is\nreturned. If the argument is NaN, then NaN is returned. If the\nargument is positive infinity, then positive infinity is returned.  If\nthe argument is negative infinity, then negative infinity is\nreturned. If the argument is positive zero, then positive zero is\nreturned.  If the argument is negative zero, then negative zero is\nreturned.  If the argument is less than zero, but greater than or\nequal to -0.5, then negative zero is returned.</p>\n\n<blockquote>\n<b>NOTE: </b>For these last two cases, the result of calling the\n<b><a href=\"#function-round\">round</a></b> function is not the same as the result of\nadding 0.5 and then calling the <b><a href=\"#function-floor\">floor</a></b>\nfunction.</blockquote>\n\n\n\n\n\n\n\n\n<h2>\n<a name=\"data-model\"></a>5 Data Model</h2>\n\n<p>XPath operates on an XML document as a tree. This section describes\nhow XPath models an XML document as a tree.  This model is conceptual\nonly and does not mandate any particular implementation.  The\nrelationship of this model to the XML Information Set <a href=\"#XINFO\">[XML Infoset]</a> is described in <a href=\"#infoset\">[<b>B XML Information Set Mapping</b>]</a>.</p>\n\n<p>XML documents operated on by XPath must conform to the XML\nNamespaces Recommendation <a href=\"#XMLNAMES\">[XML Names]</a>.</p>\n\n<p>The tree contains nodes.  There are seven types of node:</p>\n\n<ul>\n\n<li>\n<p>root nodes</p>\n</li>\n\n<li>\n<p>element nodes</p>\n</li>\n\n<li>\n<p>text nodes</p>\n</li>\n\n<li>\n<p>attribute nodes</p>\n</li>\n\n<li>\n<p>namespace nodes</p>\n</li>\n\n<li>\n<p>processing instruction nodes</p>\n</li>\n\n<li>\n<p>comment nodes</p>\n</li>\n\n</ul>\n\n<p>\n<a name=\"dt-string-value\"></a>For every type of\nnode, there is a way of determining a <b>string-value</b> for a\nnode of that type.  For some types of node, the string-value is part\nof the node; for other types of node, the string-value is computed\nfrom the string-value of descendant nodes.</p>\n\n<blockquote>\n<b>NOTE: </b>For element nodes and root nodes, the string-value of a node\nis not the same as the string returned by the DOM\n<code>nodeValue</code> method (see <a href=\"#DOM\">[DOM]</a>).</blockquote>\n\n<p>\n<a name=\"dt-expanded-name\"></a>Some types of\nnode also have an <b>expanded-name</b>, which is a pair\nconsisting of a local part and a namespace URI. The local part is a\nstring.  The namespace URI is either null or a string.  The namespace\nURI specified in the XML document can be a URI reference as defined in\n<a href=\"#RFC2396\">[RFC2396]</a>; this means it can have a fragment identifier\nand can be relative.  A relative URI should be resolved into an\nabsolute URI during namespace processing: the namespace URIs of\n<a href=\"#dt-expanded-name\">expanded-name</a>s of nodes in\nthe data model should be absolute. Two <a href=\"#dt-expanded-name\">expanded-name</a>s are equal if they have\nthe same local part, and either both have a null namespace URI or both\nhave non-null namespace URIs that are equal.</p>\n\n<p>\n<a name=\"dt-document-order\"></a>There is an\nordering, <b>document order</b>, defined on all the nodes in the\ndocument corresponding to the order in which the first character of\nthe XML representation of each node occurs in the XML representation\nof the document after expansion of general entities.  Thus, the root\nnode will be the first node. Element nodes occur before their\nchildren. Thus, document order orders element nodes in order of the\noccurrence of their start-tag in the XML (after expansion of\nentities). The attribute nodes and namespace nodes of an element occur\nbefore the children of the element.  The namespace nodes are defined\nto occur before the attribute nodes. The relative order of namespace\nnodes is implementation-dependent.  The relative order of attribute\nnodes is implementation-dependent. <a name=\"dt-reverse-document-order\"></a><b>Reverse document order</b> is the reverse of <a href=\"#dt-document-order\">document order</a>.</p>\n\n<p>Root nodes and element nodes have an ordered list of child nodes.\nNodes never share children: if one node is not the same node as\nanother node, then none of the children of the one node will be the\nsame node as any of the children of another node.  <a name=\"dt-parent\"></a>Every node other than the root node has\nexactly one <b>parent</b>, which is either an element node or\nthe root node. A root node or an element node is the parent\nof each of its child nodes. <a name=\"dt-descendants\"></a>The <b>descendants</b> of a node are the\nchildren of the node and the descendants of the children of the\nnode.</p>\n\n\n<h3>\n<a name=\"root-node\"></a>5.1 Root Node</h3>\n\n<p>The root node is the root of the tree.  A root node does not occur\nexcept as the root of the tree.  The element node for the document\nelement is a child of the root node.  The root node also has as\nchildren processing instruction and comment nodes for processing\ninstructions and comments that occur in the prolog and after the end\nof the document element.</p>\n\n<p>The <a href=\"#dt-string-value\">string-value</a> of the\nroot node is the concatenation of the <a href=\"#dt-string-value\">string-value</a>s of all text node\n<a href=\"#dt-descendants\">descendants</a> of the root\nnode in document order.</p>\n\n<p>The root node does not have an <a href=\"#dt-expanded-name\">expanded-name</a>.</p>\n\n\n\n\n<h3>\n<a name=\"element-nodes\"></a>5.2 Element Nodes</h3>\n\n<p>There is an element node for every element in the document.  An\nelement node has an <a href=\"#dt-expanded-name\">expanded-name</a> computed by expanding\nthe <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> of the element\nspecified in the tag in accordance with the XML Namespaces\nRecommendation <a href=\"#XMLNAMES\">[XML Names]</a>.  The namespace URI of the\nelement's <a href=\"#dt-expanded-name\">expanded-name</a> will\nbe null if the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> has no\nprefix and there is no applicable default namespace.</p>\n\n<blockquote>\n<b>NOTE: </b>In the notation of Appendix A.3 of <a href=\"#XMLNAMES\">[XML Names]</a>,\nthe local part of the expanded-name corresponds to the\n<code>type</code> attribute of the <code>ExpEType</code> element; the\nnamespace URI of the expanded-name corresponds to the <code>ns</code>\nattribute of the <code>ExpEType</code> element, and is null if the\n<code>ns</code> attribute of the <code>ExpEType</code> element is\nomitted.</blockquote>\n\n<p>The children of an element node are the element nodes, comment\nnodes, processing instruction nodes and text nodes for its content.\nEntity references to both internal and external entities are expanded.\nCharacter references are resolved.</p>\n\n<p>The <a href=\"#dt-string-value\">string-value</a> of an\nelement node is the concatenation of the <a href=\"#dt-string-value\">string-value</a>s of all text node\n<a href=\"#dt-descendants\">descendants</a> of the element\nnode in document order.</p>\n\n\n<h4>\n<a name=\"unique-id\"></a>5.2.1 Unique IDs</h4>\n\n<p>An element node may have a unique identifier (ID).  This is the\nvalue of the attribute that is declared in the DTD as type\n<code>ID</code>.  No two elements in a document may have the same\nunique ID.  If an XML processor reports two elements in a document as\nhaving the same unique ID (which is possible only if the document is\ninvalid) then the second element in document order must be treated as\nnot having a unique ID.</p>\n\n<blockquote>\n<b>NOTE: </b>If a document does not have a DTD, then no element in the\ndocument will have a unique ID.</blockquote>\n\n\n\n\n\n\n<h3>\n<a name=\"attribute-nodes\"></a>5.3 Attribute Nodes</h3>\n\n<p>Each element node has an associated set of attribute nodes; the\nelement is the <a href=\"#dt-parent\">parent</a> of each of\nthese attribute nodes; however, an attribute node is not a child of\nits parent element.</p>\n\n<blockquote>\n<b>NOTE: </b>This is different from the DOM, which does not treat the\nelement bearing an attribute as the parent of the attribute (see\n<a href=\"#DOM\">[DOM]</a>).</blockquote>\n\n<p>Elements never share attribute nodes: if one element node is not\nthe same node as another element node, then none of the attribute\nnodes of the one element node will be the same node as the attribute\nnodes of another element node.</p>\n\n<blockquote>\n<b>NOTE: </b>The <code>=</code> operator tests whether two nodes have the\nsame value, <i>not</i> whether they are the same node.  Thus\nattributes of two different elements may compare as equal using\n<code>=</code>, even though they are not the same node.</blockquote>\n\n<p>A defaulted attribute is treated the same as a specified attribute.\nIf an attribute was declared for the element type in the DTD, but the\ndefault was declared as <code>#IMPLIED</code>, and the attribute was\nnot specified on the element, then the element's attribute set does\nnot contain a node for the attribute.</p>\n\n<p>Some attributes, such as <code>xml:lang</code> and\n<code>xml:space</code>, have the semantics that they apply to all\nelements that are descendants of the element bearing the attribute,\nunless overridden with an instance of the same attribute on another\ndescendant element.  However, this does not affect where attribute\nnodes appear in the tree: an element has attribute nodes only for\nattributes that were explicitly specified in the start-tag or\nempty-element tag of that element or that were explicitly declared in\nthe DTD with a default value.</p>\n\n<p>An attribute node has an <a href=\"#dt-expanded-name\">expanded-name</a> and a <a href=\"#dt-string-value\">string-value</a>.  The <a href=\"#dt-expanded-name\">expanded-name</a> is computed by\nexpanding the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> specified in\nthe tag in the XML document in accordance with the XML Namespaces\nRecommendation <a href=\"#XMLNAMES\">[XML Names]</a>.  The namespace URI of the\nattribute's name will be null if the <a href=\"http://www.w3.org/TR/REC-xml-names#NT-QName\">QName</a> of the attribute does not have\na prefix.</p>\n\n<blockquote>\n<b>NOTE: </b>In the notation of Appendix A.3 of <a href=\"#XMLNAMES\">[XML Names]</a>,\nthe local part of the expanded-name corresponds to the\n<code>name</code> attribute of the <code>ExpAName</code> element; the\nnamespace URI of the expanded-name corresponds to the <code>ns</code>\nattribute of the <code>ExpAName</code> element, and is null if the\n<code>ns</code> attribute of the <code>ExpAName</code> element is\nomitted.</blockquote>\n\n<p>An attribute node has a <a href=\"#dt-string-value\">string-value</a>.  The <a href=\"#dt-string-value\">string-value</a> is the normalized value\nas specified by the XML Recommendation <a href=\"#XML\">[XML]</a>.  An\nattribute whose normalized value is a zero-length string is not\ntreated specially: it results in an attribute node whose <a href=\"#dt-string-value\">string-value</a> is a zero-length\nstring.</p>\n\n<blockquote>\n<b>NOTE: </b>It is possible for default attributes to be declared in an\nexternal DTD or an external parameter entity.  The XML Recommendation\ndoes not require an XML processor to read an external DTD or an\nexternal parameter unless it is validating. A stylesheet or other facility that assumes\nthat the XPath tree contains default attribute values declared in an\nexternal DTD or parameter entity may not work with some non-validating\nXML processors.</blockquote>\n\n<p>There are no attribute nodes corresponding to attributes that\ndeclare namespaces (see <a href=\"#XMLNAMES\">[XML Names]</a>).</p>\n\n\n\n\n<h3>\n<a name=\"namespace-nodes\"></a>5.4 Namespace Nodes</h3>\n\n<p>Each element has an associated set of namespace nodes, one for each\ndistinct namespace prefix that is in scope for the element (including\nthe <code>xml</code> prefix, which is implicitly declared by the XML\nNamespaces Recommendation <a href=\"#XMLNAMES\">[XML Names]</a>) and one for\nthe default namespace if one is in scope for the element.  The element\nis the <a href=\"#dt-parent\">parent</a> of each of these\nnamespace nodes; however, a namespace node is not a child of\nits parent element.  Elements never share namespace nodes: if one element\nnode is not the same node as another element node, then none of the\nnamespace nodes of the one element node will be the same node as the\nnamespace nodes of another element node. This means that an element\nwill have a namespace node:</p>\n\n<ul>\n\n<li>\n<p>for every attribute on the element whose name starts with\n<code>xmlns:</code>;</p>\n</li>\n\n<li>\n<p>for every attribute on an ancestor element whose name starts\n<code>xmlns:</code> unless the element itself or a nearer ancestor\nredeclares the prefix;</p>\n</li>\n\n<li>\n\n<p>for an <code>xmlns</code> attribute, if the element or some\nancestor has an <code>xmlns</code> attribute, and the value of the\n<code>xmlns</code> attribute for the nearest such element is\nnon-empty</p>\n\n<blockquote>\n<b>NOTE: </b>An attribute <code>xmlns=\"\"</code> \"undeclares\"\nthe default namespace (see <a href=\"#XMLNAMES\">[XML Names]</a>).</blockquote>\n\n</li>\n\n</ul>\n\n<p>A namespace node has an <a href=\"#dt-expanded-name\">expanded-name</a>: the local part is\nthe namespace prefix (this is empty if the namespace node is for the\ndefault namespace); the namespace URI is always null.</p>\n\n<p>The <a href=\"#dt-string-value\">string-value</a> of a\nnamespace node is the namespace URI that is being bound to the\nnamespace prefix; if it is relative, it must be resolved just like a\nnamespace URI in an <a href=\"#dt-expanded-name\">expanded-name</a>.</p>\n\n\n\n\n\n<h3>\n<a name=\"section-Processing-Instruction-Nodes\"></a>5.5 Processing Instruction Nodes</h3>\n\n<p>There is a processing instruction node for every processing\ninstruction, except for any processing instruction that occurs within\nthe document type declaration.</p>\n\n<p>A processing instruction has an <a href=\"#dt-expanded-name\">expanded-name</a>: the local part is\nthe processing instruction's target; the namespace URI is null.  The\n<a href=\"#dt-string-value\">string-value</a> of a processing\ninstruction node is the part of the processing instruction following\nthe target and any whitespace.  It does not include the terminating\n<code>? </code>.</p>\n\n<blockquote>\n<b>NOTE: </b>The XML declaration is not a processing instruction.\nTherefore, there is no processing instruction node corresponding to the\nXML declaration.</blockquote>\n\n\n\n\n<h3>\n<a name=\"section-Comment-Nodes\"></a>5.6 Comment Nodes</h3>\n\n<p>There is a comment node for every comment, except for any comment that\noccurs within the document type declaration.</p>\n\n<p>The <a href=\"#dt-string-value\">string-value</a> of\ncomment is the content of the comment not including the opening\n<code> !--</code> or the closing <code>-- </code>.</p>\n\n<p>A comment node does not have an <a href=\"#dt-expanded-name\">expanded-name</a>.</p>\n\n\n\n\n<h3>\n<a name=\"section-Text-Nodes\"></a>5.7 Text Nodes</h3>\n\n<p>Character data is grouped into text nodes.  As much character data\nas possible is grouped into each text node: a text node never has an\nimmediately following or preceding sibling that is a text node.  The\n<a href=\"#dt-string-value\">string-value</a> of a text node\nis the character data.  A text node always has at least one character\nof data.</p>\n\n<p>Each character within a CDATA section is treated as character data.\nThus, <code> ![CDATA[ ]] </code> in the source document will\ntreated the same as <code> lt;</code>.  Both will result in a\nsingle <code> </code> character in a text node in the tree.  Thus, a\nCDATA section is treated as if the <code> ![CDATA[</code> and\n<code>]] </code> were removed and every occurrence of\n<code> </code> and <code> </code> were replaced by\n<code> lt;</code> and <code> amp;</code> respectively.</p>\n\n<blockquote>\n<b>NOTE: </b>When a text node that contains a <code> </code> character\nis written out as XML, the <code> </code> character must be escaped\nby, for example, using <code> lt;</code>, or including it in a\nCDATA section.</blockquote>\n\n<p>Characters inside comments, processing instructions and attribute\nvalues do not produce text nodes. Line-endings in external entities\nare normalized to #xA as specified in the XML Recommendation <a href=\"#XML\">[XML]</a>.</p>\n\n<p>A text node does not have an <a href=\"#dt-expanded-name\">expanded-name</a>.</p>\n\n\n\n\n\n\n<h2>\n<a name=\"section-Conformance\"></a>6 Conformance</h2>\n\n<p>XPath is intended primarily as a component that can be used by\nother specifications. Therefore, XPath relies on specifications that\nuse XPath (such as <a href=\"#XPTR\">[XPointer]</a> and <a href=\"#XSLT\">[XSLT]</a>) to\nspecify criteria for conformance of implementations of XPath and does\nnot define any conformance criteria for independent implementations of\nXPath.</p>\n\n\n\n\n\n<hr title=\"Separator from footer\"/>\n\n<h2>\n<a name=\"section-References\"></a>A References</h2>\n\n<h3>\n<a name=\"section-Normative-References\"></a>A.1 Normative References</h3>\n\n<dl>\n\n<dt>\n<a name=\"IEEE754\">IEEE 754</a>\n</dt>\n<dd>Institute of Electrical and\nElectronics Engineers. <i>IEEE Standard for Binary Floating-Point\nArithmetic</i>. ANSI/IEEE Std 754-1985.</dd>\n\n<dt>\n<a name=\"RFC2396\">RFC2396</a>\n</dt>\n<dd>T. Berners-Lee, R. Fielding, and\nL. Masinter.  <i>Uniform Resource Identifiers (URI): Generic\nSyntax</i>. IETF RFC 2396. See <a href=\"http://www.ietf.org/rfc/rfc2396.txt\">http://www.ietf.org/rfc/rfc2396.txt</a>.</dd>\n\n<dt>\n<a name=\"XML\">XML</a>\n</dt>\n<dd>World Wide Web Consortium. <i>Extensible\nMarkup Language (XML) 1.0.</i> W3C Recommendation. See <a href=\"http://www.w3.org/TR/1998/REC-xml-19980210\">http://www.w3.org/TR/1998/REC-xml-19980210</a>\n</dd>\n\n<dt>\n<a name=\"XMLNAMES\">XML Names</a>\n</dt>\n<dd>World Wide Web\nConsortium. <i>Namespaces in XML.</i> W3C Recommendation. See\n<a href=\"http://www.w3.org/TR/REC-xml-names\">http://www.w3.org/TR/REC-xml-names</a>\n</dd>\n\n</dl>\n\n\n<h3>\n<a name=\"section-Other-References\"></a>A.2 Other References</h3>\n\n<dl>\n\n<dt>\n<a name=\"CHARMOD\">Character Model</a>\n</dt>\n<dd>World Wide Web Consortium.\n<i>Character Model for the World Wide Web.</i> W3C Working\nDraft. See <a href=\"http://www.w3.org/TR/WD-charmod\">http://www.w3.org/TR/WD-charmod</a>\n</dd>\n\n<dt>\n<a name=\"DOM\">DOM</a>\n</dt>\n<dd>World Wide Web Consortium.  <i>Document\nObject Model (DOM) Level 1 Specification.</i> W3C\nRecommendation. See <a href=\"http://www.w3.org/TR/REC-DOM-Level-1\">http://www.w3.org/TR/REC-DOM-Level-1</a>\n</dd>\n\n<dt>\n<a name=\"JLS\">JLS</a>\n</dt>\n<dd>J. Gosling, B. Joy, and G. Steele.  <i>The\nJava Language Specification</i>. See <a href=\"http://java.sun.com/docs/books/jls/index.html\">http://java.sun.com/docs/books/jls/index.html</a>.</dd>\n\n<dt>\n<a name=\"ISO10646\">ISO/IEC 10646</a>\n</dt>\n<dd>ISO (International\nOrganization for Standardization).  <i>ISO/IEC 10646-1:1993,\nInformation technology -- Universal Multiple-Octet Coded Character Set\n(UCS) -- Part 1: Architecture and Basic Multilingual Plane</i>.\nInternational Standard. See <a href=\"http://www.iso.ch/cate/d18741.html\">http://www.iso.ch/cate/d18741.html</a>.</dd>\n\n<dt>\n<a name=\"TEI\">TEI</a>\n</dt>\n<dd>C.M. Sperberg-McQueen, L. Burnard\n<i>Guidelines for Electronic Text Encoding and\nInterchange</i>. See <a href=\"http://etext.virginia.edu/TEI.html\">http://etext.virginia.edu/TEI.html</a>.</dd>\n\n<dt>\n<a name=\"UNICODE\">Unicode</a>\n</dt>\n<dd>Unicode Consortium. <i>The Unicode\nStandard</i>.  See <a href=\"http://www.unicode.org/unicode/standard/standard.html\">http://www.unicode.org/unicode/standard/standard.html</a>.</dd>\n\n<dt>\n<a name=\"XINFO\">XML Infoset</a>\n</dt>\n<dd>World Wide Web\nConsortium. <i>XML Information Set.</i> W3C Working Draft. See\n<a href=\"http://www.w3.org/TR/xml-infoset\">http://www.w3.org/TR/xml-infoset</a>\n</dd>\n\n<dt>\n<a name=\"XPTR\">XPointer</a>\n</dt>\n<dd>World Wide Web Consortium. <i>XML\nPointer Language (XPointer).</i> W3C Working Draft. See <a href=\"http://www.w3.org/TR/WD-xptr\">http://www.w3.org/TR/WD-xptr</a>\n</dd>\n\n<dt>\n<a name=\"XQL\">XQL</a>\n</dt>\n<dd>J. Robie, J. Lapp, D. Schach.\n<i>XML Query Language (XQL)</i>. See\n<a href=\"http://www.w3.org/TandS/QL/QL98/pp/xql.html\">http://www.w3.org/TandS/QL/QL98/pp/xql.html</a>\n</dd>\n\n<dt>\n<a name=\"XSLT\">XSLT</a>\n</dt>\n<dd>World Wide Web Consortium.  <i>XSL\nTransformations (XSLT).</i> W3C Recommendation.  See <a href=\"http://www.w3.org/TR/xslt\">http://www.w3.org/TR/xslt</a>\n</dd>\n\n</dl>\n\n\n\n\n\n<h2>\n<a name=\"infoset\"></a>B XML Information Set Mapping (Non-Normative)</h2>\n\n<p>The nodes in the XPath data model can be derived from the\ninformation items provided by the XML Information Set <a href=\"#XINFO\">[XML Infoset]</a> as follows:</p>\n\n<blockquote>\n<b>NOTE: </b>A new version of the XML Information Set Working Draft, which\nwill replace the May 17 version, was close to completion at the time\nwhen the preparation of this version of XPath was completed and was\nexpected to be released at the same time or shortly after the release\nof this version of XPath.  The mapping is given for this new version\nof the XML Information Set Working Draft. If the new version of the\nXML Information Set Working has not yet been released, W3C members may\nconsult the internal Working Group version <a href=\"http://www.w3.org/XML/Group/1999/09/WD-xml-infoset-19990915.html\">\nhttp://www.w3.org/XML/Group/1999/09/WD-xml-infoset-19990915.html</a>\n(<a href=\"http://cgi.w3.org/MemberAccess/\">members\nonly</a>).</blockquote>\n\n<ul>\n\n<li>\n<p>The root node comes from the document information item.  The\nchildren of the root node come from the <i>children</i> and <i>children - comments</i>\nproperties.</p>\n</li>\n\n<li>\n<p>An element node comes from an element information item.  The\nchildren of an element node come from the <i>children</i> and <i>children - comments</i> properties. The\nattributes of an element node come from the <i>attributes</i> property.  The namespaces\nof an element node come from the <i>in-scope namespaces</i> property.  The\nlocal part of the <a href=\"#dt-expanded-name\">expanded-name</a> of the element node\ncomes from the <i>local name</i>\nproperty.  The namespace URI of the <a href=\"#dt-expanded-name\">expanded-name</a> of the element node\ncomes from the <i>namespace URI</i>\nproperty. The unique ID of the element node comes from the <i>children</i> property of the attribute\ninformation item in the <i>attributes</i> property that has an <i>attribute type</i> property equal to\n<code>ID</code>.</p>\n</li>\n\n<li>\n<p>An attribute node comes from an attribute information item.\nThe local part of the <a href=\"#dt-expanded-name\">expanded-name</a> of the attribute node\ncomes from the <i>local name</i>\nproperty.  The namespace URI of the <a href=\"#dt-expanded-name\">expanded-name</a> of the attribute node\ncomes from the <i>namespace URI</i>\nproperty. The <a href=\"#dt-string-value\">string-value</a> of\nthe node comes from concatenating the <i>character code</i> property of each member\nof the <i>children</i>\nproperty.</p>\n</li>\n\n<li>\n<p>A text node comes from a sequence of one or more consecutive\ncharacter information items.  The <a href=\"#dt-string-value\">string-value</a> of the node comes from\nconcatenating the <i>character code</i>\nproperty of each of the character information items.</p>\n</li>\n\n<li>\n<p>A processing instruction node comes from a processing\ninstruction information item.  The local part of the <a href=\"#dt-expanded-name\">expanded-name</a> of the node comes from\nthe <i>target</i> property. (The\nnamespace URI part of the <a href=\"#dt-expanded-name\">expanded-name</a> of the node is null.)\nThe <a href=\"#dt-string-value\">string-value</a> of the node\ncomes from the <i>content</i>\nproperty. There are no processing instruction nodes for processing\ninstruction items that are children of document type declaration\ninformation item.</p>\n</li>\n\n<li>\n<p>A comment node comes from a comment information item.  The\n<a href=\"#dt-string-value\">string-value</a> of the node\ncomes from the <i>content</i> property.\nThere are no comment nodes for comment information items that are\nchildren of document type declaration information item.</p>\n</li>\n\n<li>\n<p>A namespace node comes from a namespace declaration\ninformation item.  The local part of the <a href=\"#dt-expanded-name\">expanded-name</a> of the node comes from\nthe <i>prefix</i> property.  (The\nnamespace URI part of the <a href=\"#dt-expanded-name\">expanded-name</a> of the node is null.)\nThe <a href=\"#dt-string-value\">string-value</a> of the node\ncomes from the <i>namespace URI</i>\nproperty.</p>\n</li>\n\n</ul>\n\n\n\n\n</body>\n</html>";
		var parseXML = function( data ) {
			if ( typeof data !== "string" || !data ) {
				return null;
			}
			var xml, tmp;
			try {
				if ( window.DOMParser ) { // Standard
					tmp = new DOMParser();
					xml = tmp.parseFromString( data , "text/xml" );
				} else { // IE
					xml = new ActiveXObject( "Microsoft.XMLDOM" );
					xml.async = "false";
					xml.loadXML( data );
				}
			} catch( e ) {
				xml = undefined;
			}
			if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
				throw new Error( "Invalid XML: " + data );
			}
			return xml;
		};

		XMLDOC = parseXML(templateString);
	</script>
</head>
<body>
	<script>
		var suite, callback;
		(function() {
			var parts, engine,
				params = {},
				search = location.search.substring(1).split("&"),
				i = 0,
				len = search.length;

			// Construct parameters object
			for ( ; i < len; i++ ) {
				parts = search[i].split("=");
				params[ decodeURIComponent(parts[0]) ] = parts[1] ? decodeURIComponent( parts[1] ) : "true";
			}

			suite = params.suite;
			callback = params.callback;

			if ( (engine = params.engine) && engine !== "qsa" ) {

				// Nullify QSA for testing
				// unless otherwise specified
				if ( params.qsa !== "true" ) {
					document.querySelector = document.querySelectorAll = null;
				}

				if ( engine === "query" ) {
					engine = "../../../src/query.js";
				} else {
					engine = "../frameworks/" + engine + ".js";
				}

				document.write("<scr" + "ipt src='" + engine + "'></scr" + "ipt>");
			}
		})();
	</script>
	<script>
		// Using OR here to throw an error if one is present but not the other
		// Does not throw an error if someone is just looking at this page
		if ( suite != null || callback != null ) {
			window.parent.iframeCallbacks[ suite ][ callback ].call( window, XMLDOC );
		}
	</script>
</body>
</html>
